moc Posted April 15, 2015 Share Posted April 15, 2015 14-Apr 10:35:18 Type #: 12313-TLD 14-Apr 10:35:18 IDD: 111 14-Apr 10:35:18 14-Apr 10:35:18 Sing 0000142E 14-Apr 10:35:18 Dance 0124 14-Apr 10:35:19 Read 0000000G 14-Apr 10:35:19 Jump 00000078 14-Apr 10:35:19 Study 00000007 14-Apr 10:35:19 TotalDuration 0123 14-Apr 10:35:19 TotalUsed 199D 14-Apr 10:35:19 TYPE 00000228 Hi, Can anyone help? I have two question here. Qns1: How to read the above Text File and edit in new Text file to below presentation? Sing 0000142E Dance 0124 Read 0000000G Jump 00000078 Study 00000007 TotalDuration 0123 TotalUsed 199D TYPE 00000228 Qns2: From Qns1 pull out TotalUsed 199D and compare the number not greater than 8000 in dec? Link to comment Share on other sites More sharing options...
kylomas Posted April 15, 2015 Share Posted April 15, 2015 moc, This should get you started... #include <String.au3> #include <array.au3> local $a10 = stringsplit(fileread(@scriptdir & '\strip.txt'),@CRLF,3), $out, $tot for $1 = 3 to ubound($a10) - 1 $out &= stringmid($a10[$1],18) & @CRLF if stringinstr($a10[$1],'totalused') then $tot = stringright($a10[$1],4) next ConsoleWrite($out & @CRLF) ConsoleWrite('TotalUsed (' & int('0x' & $tot) & ') is ' & (int('0x' & $tot) > 8000 ? 'greater' : 'less') & ' than 8000' & @CRLF) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
moc Posted April 17, 2015 Author Share Posted April 17, 2015 Thanks Kylomas! I change to _FileWriteLog. And the result I get is 2015-04-17 14:49:57 : ing 0000142E ance 0124 ead 0000000G ump 00000078 tudy 00000007 otalDuration 0123 otalUsed 199D YPE 00000228 2015-04-17 14:49:57 : TotalUsed (6557) is less than 8000 And unable to get expected results as below. Pls advise. Thanks. Sing 0000142E Dance 0124 Read 0000000G Jump 00000078 Study 00000007 TotalDuration 0123 TotalUsed 199D TYPE 00000228 TotalUsed (6557) is less than 8000 #include <String.au3> #include <array.au3> #include <File.au3> #RequireAdmin local $a10 = stringsplit(fileread(@scriptdir & '\demo.txt'),@CRLF,3), $out, $tot for $1 = 3 to ubound($a10) - 1 $out &= stringmid($a10[$1],18) & @CRLF if stringinstr($a10[$1],'totalused') then $tot = stringright($a10[$1],4) next ;ConsoleWrite($out & @CRLF) ;ConsoleWrite('TotalUsed (' & int('0x' & $tot) & ') is ' & (int('0x' & $tot) > 8000 ? 'greater' : 'less') & ' than 8000' & @CRLF) _FileWriteLog(@ScriptDir & "\Example.log", $out & @CRLF) _FileWriteLog(@ScriptDir & "\Example.log", 'TotalUsed (' & int('0x' & $tot) & ') is ' & (int('0x' & $tot) > 8000 ? 'greater' : 'less') & ' than 8000' & @CRLF) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now