Now for an updated (3.0.3) version of KiXGolf 3...

This version now prints the KiXtart version under wich it was started, like this:
code:
KixGolf v3.0.3 score = 460, running under KiXtart v4.10
{edit} another example:
KixGolf v3.0.3 score = 460, running under KiXtart v4.11 RC 1
{/edit}

And here it is:
code:
; KixGolf.kix  (Version 3)
;
$Version = "3.0.3" ; (2002/08/24@13:15) - Fernando Madruga
; Now prints KiXtart version too
;
;$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) + ", running under KiXtart v" + @KIX
?

;!
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
;--------------------------------------------------------------------------------------------------

Later,
Madruga

[ 24. August 2002, 14:20: Message edited by: Fernando Madruga ]
_________________________
Later,   [b]Mad[/b]ruga