sorry, for some reason the email-notify doesnt work for me.

Anyway, i took all your suggestions under advice. Thanks!
The mentioned problems are gone, but somehow i managed to implement a new one.

It must have happend somewhere on the way and i cant fix it atm.
If you look at the exportfile at the bottom, it seems that sometimes the script doesnt stop at the end of a line and add the next line to a variablestring.

This is the current state of the script:

Code:
 
; ===========================================================================================
;
; Script Information
;
$Title = "VarScan 1.1b"
; Author: therob / Function combsort () by Shawn Tassie
; Description: Scans kixfiles for Variables and missing quotes and writes a reportfile
; -> Syntax of the reportfile: [variable] - [linenumbers in which the variable is used]
;
; ===========================================================================================


Break On

;.. variables

$match = 0
$Var = "$"
$stopchars = " <>()+-.,'#;:?=/&\}][{*!@@"
$TextMode = 1
$dictAllVars = CreateObject ("Scripting.Dictionary")
$dictAllVars.CompareMode = $TextMode
$VarNames = $dictAllVars.Keys
$allLines = "none"
$VarCount = 0
$orphans = ""
$orphcount = 0
$linecount = 0
$quote1 = 0
$quote2 = 0

;... select source

$System = CreateObject("Kixtart.System")

$openFile = $System.openFileDialog()
$openFile.Title = "Open a script to scan"
$openFile.InitialDirectory = @curDIR
$openFile.Filter = "All files (*.*)|*.*"
$openFile.Title = "Select a kixfile to scan..."
$openFile.DefaultExt = "kix"
$openFile.ShowDialog()

$input = $OpenFile.FileName
$report = $input + "-VarScanReport.txt"

$ = Open (1,$FileName,2)
If $input = ""
$rc = MessageBox("No file selected.", "Whoo", 262208, 5)
Quit
EndIf


; ..
; ... scan file

$=Open (1,$input,2)
$Line = ReadLine(1)

While NOT @error

If $quote1 = 1 OR $quote2 =1
$quoterror = $quoterror + "Attention: Presumably a missing quotation mark in: "+ @CRLF + $linecount + " " + $curline + @crlf +@crlf
$quoteErrCount = $quoteErrCount + 1
EndIf
$quote1 = 0 $quote2 = 0
$linecount = $linecount + 1

For $c = 1 to Len($Line)
$Char = SubStr ($Line, $c, 1)

If $Char = ";" AND NOT ($quote1 = 1 OR $quote2 = 1)
GoTo readAline
EndIf

If $Char = "$"
$match = 1
EndIf

If $match = 1 AND NOT $char ="$"
If InStr ($stopchars,$char) <> 0 OR Asc ($char) = 34

; .. add to Dict
If $dictAllVars.Exists($var)
$tempLines = $dictAllVars.Item ($var)
$allLines = $tempLines + ", " + $linecount
DictionarySet ($dictAllVars,"$var","$allLines")
Else
$allLines = $linecount
DictionarySet ($dictAllVars,"$var","$allLines")
EndIf

$Match = 0 $Var = "$"
Else
$Var = $var + $char
EndIf
EndIf

Select ;look for --> "
Case $Char = '"' AND $quote1 = 1
$quote1 = 0
Case $Char = '"'
$quote1 = 1
$curline = $line
EndSelect

Select ;look for --> '
Case $Char = "'" AND $quote2 = 1
$quote2 = 0
Case $Char = "'"
$quote2 = 1
$curline = $line
EndSelect
Next

:readAline

Select
Case Len ($linecount) = 1 $wslinecount = "000" + $linecount
Case Len ($linecount) = 2 $wslinecount = "00" + $linecount
Case Len ($linecount) = 3 $wslinecount = "0" + $linecount
Case 1 $wslinecount = $linecount
EndSelect
$wholescript = $wholescript + $wslinecount + " " + $line + @CRLF

$Line = ReadLine(1)
Loop


; ..
; ... sort and write report

If Exist ($report) Del $report EndIf
$ = Open (2,$report,5)
$ = WriteLine (2, $Title + " / Scanned file: "+$input+ @CRLF+ @CRLF)

; ..Sort Dict

For Each $VarNameA In $dictAllVars.Keys
$VarCount = $VarCount + 1
$VarString = $VarString + "," + $VarNameA
Next
$varArray = combsort (Split (SubStr ($VarString,2),","))

;... search for orphans and export the variables

For Each $VarName In $varArray

$VarLines = $dictAllVars.Item ($VarName)

If NOT InStr ($Varlines,",")
$orphans = $orphans + $varname + " " + $Varlines + @CRLF
$orphcount = $orphcount + 1
EndIf

$reportline = $Varname + " " + $VarLines + @CRLF
$ = WriteLine (2,$reportline)

Next

;... export rest

$ = WriteLine (2, "-----------------------"+@CRLF+ "All Variables: "+ $VarCount )
$ = WriteLine (2, @CRLF+@CRLF+ @CRLF+ "Orphans: " + $orphcount + @CRLF+ "-----------------------"+ @CRLF + $orphans)

If $quoteErrCount > 0
$ = WriteLine (2, @CRLF+@CRLF+ @CRLF+ "Possible Quote-Errors: " + $quoteErrCount + @CRLF+ "-----------------------"+ @CRLF+ $quoterror)
Else
$ = WriteLine (2, @CRLF+@CRLF+ @CRLF+ "No Quote-Errors found.")
EndIf

$ = WriteLine (2, @CRLF+@CRLF+ @CRLF+ "Scanned script:"+ @CRLF+ "-------------------------"+ @CRLF + $wholescript)
$=Close (1)
$=Close (2)


Run "%COMSPEC% /c $report"
Quit 0


; ..
;... functions

Function DictionarySet ($DictionaryObject, $key, $value)
If VarTypeName($key) = "Empty"
Quit 13
EndIf

If $DictionaryObject.Exists($key)
$DictionaryObject.Remove($key)
EndIf

$DictionaryObject.Add($key, $value)
Exit @error
EndFunction

Function combsort($v, optional $o)
Dim $i,$j,$m,$s,$g
$n=Ubound($v)
$g=$n
If $g
While $g > 1 OR NOT $s
$g=($g*1000)/1279
If $g < 1
$g=1
EndIf
$s=1
For $i = 0 to $n-$g
$j=$i+$g
If ($v[$i] > $v[$j] AND NOT $o) OR ($v[$i] < $v[$j] AND $o)
$m = $v[$i]
$v[$i] = $v[$j]
$v[$j] = $m
$s=0
EndIf
Next
Loop
$combsort = $v
Else
$combsort = 0
EndIf
EndFunction



the exportfile:

Code:
  
VarScan 1.1b / Scanned file: E:\scripte\mixed\scanKixforVariables\tes3.kix

$emessage 1, 3
$errcount 3
$errcount rc 3
$TextBox4 2
-----------------------
All Variables: 4


Orphans: 3
-----------------------
$errcount 3
$errcount rc 3
$TextBox4 2



No Quote-Errors found.


Scanned script:
-------------------------
0001 Function ermes ($emessage)
0002 $TextBox4.Text = $errcount
0003 $rc= WriteLine (9," @time ;Fehler $errcount ; "+$emessage+" ###@CRLF")
0004
0005 EndFunction
0006




any suggestions?
_________________________
Eternity is a long time, especially towards the end. - W.Allan