#69319 - 2002-08-23 07:42 PM
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
Starting to like KiXtart
Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
|
Eheh... Here's 3.0.2
It's nicer (and useful) to have the version info printed alongside the score, so one does not have to look into the script...
Later, Fernando Madruga
code:
; KixGolf.kix (Version 3) ; $Version = "3.0.2" ; (2002/08/23@18:45) - Fernando Madruga ; Now prints the version code with the score ; ; V 3.0.1 (2002/08/23@18:30) - Fernando Madruga ; Fixed handling of CHR(127) and added version info ; ; This function scores the specified file and returns ; the KixGolf score. That is the total number of key strokes ; used to build a script not counting comments, spaces, tabs, ; or any ASCII character above 126. ; ; The script will start counting on "odd" (1,3,5,...) occurrences ; of ";!" and the script will stop counting after "even" (0,2,4,...) ; instances of ";!". Note that ";!" must be placed starting in column ; number 1. ; ;A debug mode has been added in this version. The debug mode ;is controlled with the use of ";~" at the beginning of the line like ; the count controller (;!) above. You start and stop debugging ;as many time as you like while counting is enabled. ; ;Debug data is written to a file in the same directory that this ;program resides. The file name is that of the target file name with ;".debug" as an extension. Data will only be written while counting is ;active. ; ;The data written if the character being analyzed, it's ASCII decimal ;value, if it was counted or not, and a running total. ; ;Syntax: %tmp%\kix32 kixgolf.kix $F=Kixgolf.kix ;
; $F must be initialized on the command line. ; Syntax: kix32 kixgolf.kix $F=test.kix ? ? "KixGolf v" + $Version + " score = " + KixGolf($F) ?
;! Function KixGolf($F) $debugfile=@ScriptDir+"\"+$F+".debug" Del $debugfile $Line=0 $Y=0 $D=0 $S=0 if open (1,$F) = 0 Do if $L $Line = $Line + 1 $ZZ = (left($L,2)=";~") $debug = $debug + $ZZ & 1 if $debug & $olddebug<>$debug WriteLog2($debugfile,"Debug Started at Line: " + $Line,1) WriteLog2($debugfile,"--------------------------------------------------") $olddebug=$debug endif if not $debug & $olddebug<>$debug WriteLog2($debugfile,"--------------------------------------------------") WriteLog2($debugfile,"Debug Stopped at Line: " + $Line,1) $olddebug=$debug endif $Z = (left($L,2)=";!") $Y = $Y + $Z & 1 if not $Z & not $ZZ $x=len($L) for $h=1 to $x $A=asc(substr($L,$h,1))-32 $D = $D + ($A=2) & 1 & not $S $S = $S + ($A=7) & 1 & not $D if $debug $Q = $D | $S if $Q<>$oldQ if $Q WriteLog2($debugfile,"Quotes ON at: " + chr($A+32)) else WriteLog2($debugfile,"Quotes OFF at: " + chr($A+32)) endif endif $oldQ=$Q endif if not $D & not $S & ($A=27) $h=$x+1 if $debug WriteLog2($debugfile,chr($A+32) + " " + ($A+32) + " Count=0 ") $text="Comment found. Ignore to EOL. Next character should be" + " 1st char of new line." WriteLog2($debugfile,$text) endif else $=$+($Y & (($A>0 & $A<96) | $D | $S)) if $debug $text=chr($A+32) + " " + ($A+32) + " Count=" + ($Y & (($A>0 & $A<96) | $D | $S)) + " " + $ WriteLog2($debugfile,$text) endif endif next endif endif $L=ReadLine(1) Until @error else "Bad File Name: $F" ? $="NA" endif if $D | $S ? "Mis-matched quotes. Probable score error." ? endif if $olddebug ? "Debug File: " +$debugfile ? endif $KixGolf=$ EndFunction
;-------------------------------------------------------------------------------------------------- ;FUNCTION WriteLog2() ; ;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com) ; ;ACTION Generic logging facility for scripts. Appends log entry to a file with an ; optional TimeStamp. ; ;SYNTAX WriteLog2($File, $text, [0|1]) ; ;PARAMETERS $File (Required) - String value ; $text (Required) - String value ; $TimeStamp (Optional) Default(0) no TimeStamp (1 or 0) ; ; ;REMARKS This function writes (appends) an optionally time stamped log entry to the file ; defined in function. This function searches for the first unused file handle, ; open the file, and write the entry. The file handle is then closed. When the ; function is unable to perform its it write the error is displayed in a message box. ; ;RETURNS Nothing ; ;DEPENDENCIES None ; ;EXAMPLES WriteLog2("junk.txt","This is a test") ; WriteLog2("junk.txt","This is a test",0) ; WriteLog2("junk.txt","This is a test",1) ; ; Function WriteLog2($File, $Text, optional $TimeStamp) dim $RC, $File, $text, $FH, $TimeStamp $FH=1 $RC=Open ($FH, $File, 5) while $RC = -3 $FH=$FH +1 $RC=Open ($FH, $File, 5) Loop Select Case $RC=0 if ($TimeStamp=1) $TimeStamp = @Date + " " + @Time + " - " else $TimeStamp = "" endif $RC=Writeline ($FH, $TimeStamp + $Text + @CRLF) $RC=Close ($FH) Case $RC=-2 $text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File." $RC=MessageBox ($text,"Script Error",48) Case $RC=-1 $text = "WriteLog2: Invalid file name ($File) specified for log file." $RC=MessageBox ($text,"Script Error",48) Case $RC=>0 $text = "System Error($RC) while attempting to open log file ($File)." $RC=MessageBox ($text,"Script Error",48) Endselect EndFunction ;--------------------------------------------------------------------------------------------------
[ 23. August 2002, 19:43: Message edited by: Fernando Madruga ]
_________________________
Later,
[b]Mad[/b]ruga
|
|
Top
|
|
|
|
KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-21 09:09 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-21 09:20 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-21 09:22 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Howard Bullock
|
2002-08-21 09:26 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
MightyR1
|
2002-08-21 11:50 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-21 11:58 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-22 12:04 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 12:09 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-22 03:42 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 11:36 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 11:38 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 12:24 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Richard H.
|
2002-08-22 01:26 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 01:30 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-22 07:45 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 07:52 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-22 07:55 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-22 08:01 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-22 08:01 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-22 08:02 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 01:06 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 01:39 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 01:52 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 02:09 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 02:14 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 02:38 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 02:40 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 02:55 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 02:59 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 03:02 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 03:05 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 03:07 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 03:15 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 03:19 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 03:23 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 03:53 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
MightyR1
|
2002-08-23 09:15 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 10:33 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 03:03 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 04:08 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 04:17 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 04:51 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 05:20 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Howard Bullock
|
2002-08-23 06:59 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Howard Bullock
|
2002-08-23 07:04 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-23 07:05 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 07:30 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 07:42 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-23 10:15 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-23 11:21 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Howard Bullock
|
2002-08-24 02:26 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-24 02:47 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-24 03:03 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-25 12:22 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-24 01:42 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-24 02:06 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-24 02:14 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-24 02:53 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-24 03:37 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-24 06:11 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Anonymous
|
2002-08-24 07:50 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-25 05:19 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-25 07:29 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-26 10:17 AM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-26 03:45 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
BrianTX
|
2002-08-26 08:30 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Sealeopard
|
2002-08-26 08:39 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
BrianTX
|
2002-08-26 08:52 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-26 08:53 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Lonkero
|
2002-08-26 09:52 PM
|
Re: KiXtart Golf Tournament IV: Anagrams (Part 2, The code!)
|
Fernando Madruga
|
2002-08-27 01:16 AM
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 962 anonymous users online.
|
|
|