Page 1 of 1
Counting Lines of Code
Posted: Thu Sep 05, 2019 1:50 pm
by gshearne
Hi,
Is there any quick/easy way to count the lines of code in a stack. I have several stacks with lots of cards and just want a simple count of the lines.
Thanks
Greg
Re: Counting Lines of Code
Posted: Thu Sep 05, 2019 1:53 pm
by Klaus
Hi Greg,
Code: Select all
...
put the num of lines of the script of stack "your stack here" into NumberOfStackScriptLines
...
Gather all infos in a repeat loop over the cards in your stack and that's it.
Best
Klaus
Re: Counting Lines of Code
Posted: Thu Sep 05, 2019 8:19 pm
by AndyP
Re: Counting Lines of Code
Posted: Fri Sep 06, 2019 2:54 pm
by dunbarx
Hi,
I did this for a large project once. I counted the total number of lines and then deducted all lines that either were empty or began with "--".
You will need to examine each card and accumulate the scripts of all the controls on each. Then add the stack script. You can do all that without actually navigating to each card right?
Craig
Re: Counting Lines of Code
Posted: Tue May 28, 2024 2:24 pm
by trevix
Hello.
I tried the script reporter opening my quite large stack, but the Script Reporter freezes just after listing all the cards and stacks.
I using LC10dp8
Re: Counting Lines of Code
Posted: Tue May 28, 2024 2:29 pm
by dunbarx
I use this to track a large project:
Code: Select all
on countLines
lock screen
set the cursor to busy
lock messages
repeat with y = 1 to the number of cds --ACCESS CURRENT STACK
put y && the number of controls of cd y into line y of tCon
put the script of cd y & return after accum
repeat with u = 1 to the number of controls of cd y
put the script of control u of cd y & return after accum
end repeat
end repeat
put the script of this stack after accum
put the substacks of this stack into stackList --ACCESS ALL SUBSTACKS
repeat with v= 1 to the number of lines of stackList
go stack line v of stacklist
if the result <> "" then
end if
repeat with y = 1 to the number of cds
put the script of cd y & return after accum
repeat with u = 1 to the number of controls of cd y
put the script of control u of cd y & return after accum
end repeat
end repeat
put return & the script of this stack after accum
end repeat
repeat for each line tline in accum
if char 1 to 2 of tLine <> "--" and tLine <> "" then add 1 to numLines --COUNT ONLY "WORKING" LINES
add 1 to totLines
end repeat
repeat with v= 1 to the number of lines of stackList --CLOSE SUBSTACKS
close stack line v of stacklist
end repeat
answer "# active Lines:" && numLines & return & "Total Lines:" && totLines
end countLines
Craig