Source language: Translate to:

Reading an external file

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Postby Sam Cox » Fri Feb 09, 2007 1:36 pm

Yep, you've got TAB characters in there. We can remove them with one additional StrReplace command. The "step 1" code becomes:
Code: Select all
FileRead "[File]" "all" "[temp]"
StrReplace "[temp]" " " "" "[temp]"
StrReplace "[temp]" "%" "" [temp]"
StrReplace "[temp]" "[#9]" "" [temp]"
FileWrite "[File]" "all" "[temp]"

where [#9] is Neobook'ese for the TAB character.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Gaev » Fri Feb 09, 2007 1:51 pm

Steve:

here is the code that works ...
Code: Select all
SetVar "[DefragFile]" "!C:\windows\temp\defrag.txt"
FileRead "[DefragFile]" "All" "[DefragAll/a]"
..Remove spaces and tab characters
StrReplace "[DefragAll/a]" "[#32]" "" "[DefragAll/b]"
StrReplace "[DefragAll/b]" "[#09]" "" "[DefragAll/c]"
... Total fragmentation Value
StrParse "[DefragAll/c]" "Totalfragmentation=" "[TFragPart]" "[junk]"
StrParse "[TFragPart2]" "!%" "[TFragValue]" "[junk]"
AlertBox "TFragValue1" "[TFragValue1]"

Gives me the correct number (without the % sign) in [TFragValue1]

For the other values, use the appropriate string values (without spaces) in this line ...
Code: Select all
StrParse "[DefragAll/c]" "Totalfragmentation=" "[TFragPart]" "[junk]"


The file contains a strange combination of space and tab characters ... so the StrReplace commands at the beginning remove all of them ... including the ones between the words you would search/parse.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

THANKS

Postby stevec » Fri Feb 09, 2007 2:49 pm

many many thanks;

here is the code that worked;

Run "!C:\temp\Icon\Dinfo.bat" "" "RunOnce+Wait+Hidden" "" ""


.step 1
SetVar "[File]" "C:\WINDOWS\Temp\defrag.txt"
FileRead "[File]" "all" "[temp]"
StrReplace "[temp]" "[#09]" "" "[temp]"
StrReplace "[temp]" " " "" "[temp]"
StrReplace "[temp]" " " "" "[temp]"
StrReplace "[temp]" "%" "" "[Temp]"
FileWrite "[File]" "all" "[temp]"

.step 2
LoadVariables "[File]"


StrParse "[TotalFragmentation]" "%" "[X]" "[unused]"
SetVar "[TotalFragmentation]" "[X1]"
StrParse "[FileFragmentation]" "[#32]" "[X]" "[unused]"
SetVar "[FileFragmentation]" "[X1]"


I investigated and also found the tab character. [#09]

I'm keeping this help.
again;
Many Many thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Previous

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests

cron