#140287 - 2005-05-25 06:49 PM
Help with Readline Loop
|
Fugazi
Starting to like KiXtart
Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
|
One thing that has always bothered me is piping out plain text files from KiXtart. I am working on this encoding routine to encode the output to file. The problem I am having is that this is only reading the first line of the test file that I am trying to encode. I am going to work on areader after I get this completed. I only have this setup for Alpha Numeric at this time specialty characters are not available yet.
Code:
Break on Dim $a,$b,$c,$sTestInfo,$sInfo,$sEncode,$sScanInfo $a=1 Open (1,"c:\temp\test.txt",5) Open (2,"c:\temp\testinfo.txt",2) $aLCase='a','b','c','d','e','f','g','h','i','j','k','l', 'm','n','o','p','q','r','s','t','u','v','w','x','y','z',' ', '1','2','3','4','5','6','7','8','9','0', '~','!','@','#','$','%','^','&','*','(',')','_', '+','?','>','<',':','"','}','{','|','\',']','[','=','-',',','.','/' $aEncode='57e4','3216','96DD','774F','G44s','nX19','56x4','Y13n','k4T0','o319','J439','7KYL','x324', '39e6','G491','2c3B','9ZiN','4qT7','E976','0Ob4','3nX4','1m43','D9I1','07QZ','07Qz','fx3J','X1x5','x4X9', 'Gg76','954N','TX1A','GWAH','4q33','xtZ0','K1n3','j517','ZN3x' $sTestinfo=ReadLine (2) While $Stestinfo <>"" Do $sScaninfo=SubStr ($sTestinfo,$a,1) For Each $sInfo in $aLCase $b=$b+1 If $sInfo=$sScaninfo AND $bSkip=0 For Each $sEncode in $aEncode $c=$c+1 If $c=$b WriteLine (1,$sEncode) $sEncode="" $bSkip=1 EndIf Next EndIf Next $bSkip=0 $b=0 $c=0 ?$sScaninfo $a=$a+1 Until $sScanInfo="" $sTestInfo= ReadLine (2) WriteLine (1,@CRLF) Loop Close (1) Close (2) Exit 0
With this code KiXtart KiXass translates to:
J439k4T007QZ0Ob457e44qT70Ob4X1x5J439k4T007QZ57e4E976E976
_________________________
I haven't failed. I just found another way that did not work.
|
|
Top
|
|
|
|
#140288 - 2005-05-25 07:09 PM
Re: Help with Readline Loop
|
NeedANewJob
Fresh Scripter
Registered: 2005-04-01
Posts: 23
|
Try putting the $a=1 at the top of your While Loop.
|
|
Top
|
|
|
|
#140289 - 2005-05-25 08:21 PM
Re: Help with Readline Loop
|
maciep
Korg Regular
   
Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
|
Made some adjustments to take advantage of ascan(). But had to comment out the non alpha-numeric elements of your array.
Code:
Dim $a,$sTestInfo,$sEncode,$sScanInfo,$index $a=1 $ = Open (1,"c:\test.txt",5) $ = Open (2,"c:\testinfo.txt") $aLCase='a','b','c','d','e','f','g','h','i','j','k','l', 'm','n','o','p','q','r','s','t','u','v','w','x','y','z',' ', '1','2','3','4','5','6','7','8','9','0';, ;'~','!','@','#','$','%','^','&','*','(',')','_', ;'+','?','>','<',':','"','}','{','|','\',']','[','=','-',',','.','/' $aEncode='57e4','3216','96DD','774F','G44s','nX19','56x4','Y13n','k4T0','o319','J439','7KYL','x324', '39e6','G491','2c3B','9ZiN','4qT7','E976','0Ob4','3nX4','1m43','D9I1','07QZ','07Qz','fx3J','X1x5','x4X9', 'Gg76','954N','TX1A','GWAH','4q33','xtZ0','K1n3','j517','ZN3x' $sTestinfo=ReadLine (2) While @error = 0 $a = 1 Do $sScaninfo=SubStr ($sTestinfo,$a,1) $index = ascan($aLCase,$sScaninfo) if $index > -1 $ = WriteLine (1,$aEncode[$index]) else $ = Writeline(1,$sScaninfo) EndIf $a=$a+1 Until $sScanInfo="" $ = WriteLine (1,@CRLF) $sTestInfo= ReadLine (2) Loop $ = Close (1) $ = Close (2) Exit 0
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 484 anonymous users online.
|
|
|