Cross Reference List (XRef)

Post your working scripts, libraries and tools
stealzy
Posts: 82
Joined: 01 Nov 2015, 13:43

Re: Cross Reference List (XRef)

12 Jan 2018, 10:10

Great obfuscation, it looks crazy ;) ! Just a small piece of your script if you don't mind:

Code: Select all

Loop Read,%fi%
{ If (ex="c")
{ L:="",z:=A_LoopReadLine,x=1,c1:=z~="^[^\s#]"
IfEqual true,% !(z~="/\*|\*/|//")&&cm!=2,SetEnv L,%z%
else while x<=StrLen(z)
{ y:=SubStr(z,x,2),(cm=2&&y="*/")?(cm:=0,L.=" ",x++)
: (cm=0&&y="/*")?(cm:=2, L.=" ",x++):0
IfEqual cm,0,IfEqual y,//,break
(cm=2)?x++:L.=SubStr(z,x++,1)
} } else { L:=A_LoopReadLine, ln:=cm=1?"":SubStr(LTrim(L),1,2)
cm:=ex="a"&&ln="/*"?2:cm
IfEqual true,% ex="d"&&ln="::"||ex="a"&&cm=2&&L~="\*/"&&!(cm:=0)||cm=2,continue
} L:=rr(rr(L,":="," "),":",ex="d"?" :":ex="a"?": ":" ")
L:=rr(rr(ex="c"?rr(L,"\s+\(","("):L,"(;|\()","$1 "),"((``.)|{|\)|,)"," $1 ")
L:=Trim(rr(L,"[^\w#@$;" co "``]+"," ")),ln#=A_Index,cr=0
Loop Parse,L,%A_Space% ; ^^ c?[ (=>(] [;(=>$1 ] [`?{),=> $1 ]
{ z:=A_LoopField,y:=SubStr(z,1,1),cr:=ex!="a"||cr?cr:y=";"
IfEqual true,% (ex="d"&&z="rem"||ex="a"&&y=";"), IfNotEqual cm,1,break
(ex="a"&&A_Index=1&&z<>","&&z<>"{")?f#:=0:0
fr:=ex="d"?y=":"?A_Index=1?"F":lw="call"?"R":" ":" "
:ex="c"? SubStr(z,0)="("?c1&&!cr++&&!(nf[z]&2)? "F":"R":" "
:ex="a"&&SubStr(z,0)="("&&!(nf[z]&1)?"R":" "
(ex="a"&&SubStr(z,0)="("&&A_Index>1)?f#:=0:0
(ex="a"&&z="{"&&lw=")"&&f#&&fu)?fu:=SubStr(fu,1,f#) "F" SubStr(fu,f#+2):0
(ex="a")?(SubStr(z,0)=":"&&A_Index=1?fr:="F":lw="gosub"?fr:="R"):0
lw:=cr?lw:z,x:=rr(z,"(^[{:]+)|([({;:,)]+$)")
IfEqual x,,continue
fu.=ln#>=lb&&(ln#<=le||!le)?x "/" ln# "/" ++ic "/" fr "|":""
(ex="a"&&SubStr(z,0)="("&&A_Index=1&&!(nf[z]&1))?f#:=StrLen(fu)-2:0
IfEqual ex,d,IfEqual A_Index,1,IfEqual y,:,IfNotEqual cm,1,break
} } SplashTextOff
nz:=StrLen(ln#)+1,s:=dp(nz),wz=0,b2=2*10**9,int=""
IfLess lz,% nz*4,MsgBox 8240,,% "Characters/line must be " nz*4 " or greater!"
IfLess lz,% nz*4,goto rpt
How do you do this?

I use Notepad++ Ctrl+F → "Find all in current document" button for this goal.
Little bug: function map display hotkeys like a:: as function.
Last edited by stealzy on 12 Jan 2018, 14:35, edited 1 time in total.
Helgef
Posts: 3299
Joined: 17 Jul 2016, 01:02
Contact:

Re: Cross Reference List (XRef)

12 Jan 2018, 10:38

@ stealzy see, someone else had similar questions ;). I reacted similarily to ReClip source code, but I found it quite easy to modify because the code was well commented, much more than your snippet, it looks a bit daunting indeed ;).

@ TAC109, I'm still using ReClip quite often, XRef, occasionally. :thumbup:

Cheers :wave:.
TAC109
Posts: 230
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Cross Reference List (XRef)

12 Jan 2018, 18:12

@stealzy - Well, my code is not quite as confusing as you portray, as you've lost the comments and indents in your shown example! Many short variable names are simple contractions of a longer more meaningful name (saves typing). The single character names near the end of the alphabet (z, y, x, etc) are like localised working registers (contents used within a few lines only).

Anyway, thanks for trying XRef. I'll look into the bug you found.

@Helgef - I haven't progressed much with the '#include' enhancement we discussed a while ago as there doesn't seem to be much demand for this facility, and I don't need it myself. I've mentally planned the method I would use, but not coded anything.

Thanks for your comments.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
TAC109
Posts: 230
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Cross Reference List (XRef)

12 Jan 2018, 18:44

stealzy wrote:Little bug: function map display hotkeys like a:: as function.
Actually, that's not a bug. For AHK scripts, XRef includes functions and labels in the 'Function Map'. As hotkeys can be the subject of 'goto' and 'gosub' commands, they are included in the report.

Cheers
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
TAC109
Posts: 230
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Cross Reference List (XRef)

13 Nov 2018, 21:59

Update 14 November 2018 -
  • The subset lines input box must now be completed or dismissed before continuing.
  • Subset XRef files created now have the supplied line number range in the file name.
  • Analysis of large scripts will now cause a readable progress tool tip to be shown.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
TAC109
Posts: 230
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Cross Reference List (XRef)

15 Nov 2018, 18:11

Update 16 November 2018 - n/up reports will now show the page number of the report in the 'page top' line.
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bing [Bot], Drugwash, robmar-zl, robodesign and 46 guests