Hi I'm rediscovering Kix after a time in the wilderness. Here's wait I am trying to do and would appreciate any help.
I have a list of names and addresses in a list format.. e.g
Name Address Street City Phone number Fax
What I am tryig to do it remove the CRLF at the end of each line (which I have done using the fnStrip function.. I can concatenate a comma after each bit of info, but, what I am not sue how to do is.. count lines and put a LFCR after each fax number. Is this possible using Kix ?
i.e. find a string count on X characters then insert a CRLF
my code so far
Function fnSTRIP($sString,OPTIONAL $sDelimeter) If VarType($sString)<>8 Exit(1) EndIf If Not $sDelimeter $sDelimeter = Chr(13) + Chr(10) EndIf $sString = Split($sString,$sDelimeter) For Each $sString in $sString $fnSTRIP=$fnSTRIP+$sString Next EndFunction
Function insertline($a, $b, optional $c, optional $d) Dim $e,$f,$h,$x,$y If $b<0 Exit -3 EndIf If $c="" $d=1 EndIf $f="%temp%\~kixil00.tmp" ; temporary file to use Del $f If $d<>1 $d=0 EndIf $e=FreeFileHandle $insertline=-2 If $e=0 Exit -2 EndIf $insertline=Open($e,$a) If $insertline<>0 Exit @Error EndIf $h=FreeFileHandle If $h=0 $insertline=-2 $x=Close($e) Exit -2 EndIf $insertline=Open($h,$f,5) If $insertline<>0 $x=Close($e) Exit @Error EndIf If $b<>0 For $x=0 To $b-1 $y=ReadLine($e) If @Error<>0 $x=Close($e) $x=Close($h) Del $f $insertline=-3 Exit -3 Else $insertline=WriteLine($h,$y+@Crlf) EndIf Next EndIf $insertline=WriteLine($h,$c) $y=ReadLine($e) If @Error<>0 $x=Close($e) $x=Close($h) Del $f $insertline=-3 Exit -3 EndIf If $d=0 $x=WriteLine($h,$y+@Crlf) EndIf $y=ReadLine($e) While @Error=0 $insertline=Writeline($h,$y+@Crlf) $y=ReadLine($e) Loop $x=Close($e) $x=Close($h) Copy $f $a Del $f $insertline=0 Exit 0 EndFunction
$FileName = Dir("c:\temp\*.csv") While $FileName <> "" and @ERROR = 0 $fullpath = ("c:\temp\" + $filename)
IF Open(3, $fullpath) = 0 $x = ReadLine(3) WHILE @ERROR = 0 $y = WriteLine( 3 , ",")
;? "Line read: [" + $x + "]"
;Strip CRLF from document fnSTRIP($x)
$x = ReadLine(3) LOOP Close (3) ELSE BEEP ? "Config file not opened, error code: [" + @ERROR + "]" ENDIF
$FileName = Dir() ; retrieve next file loop
Kind Regards
Damon
|