Counting Lines of Code
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Counting Lines of Code
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
			
			
									
									
						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
Hi Greg,
Gather all infos in a repeat loop over the cards in your stack and that's it.
Best
Klaus
			
			
									
									
						Code: Select all
...
put the num of lines of the script of stack "your stack here" into NumberOfStackScriptLines
...Best
Klaus
Re: Counting Lines of Code
Andy .... LC CLASSIC ROCKS!
						Re: Counting Lines of Code
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
			
			
									
									
						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
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
			
			
									
									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
Trevix
OSX 15.7 xCode 26.01 LC 10.0.3 RC1 iOS 15> Android 7>
						OSX 15.7 xCode 26.01 LC 10.0.3 RC1 iOS 15> Android 7>
Re: Counting Lines of Code
I use this to track a large project:
Craig
			
			
									
									
						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