Afrow UK
25th May 2003 22:54 UTC
Searching through a file
I'm getting a path (e.g. pics\temp.pcx) out of 1 line within a file (models\temp.md2).
However, the file is not pure text, so FileRead only gets to the second line and produces an error.
Is there a way to convert this file to pure text?
-Stu
kichik
25th May 2003 23:04 UTC
FileReadByte doesn't care if the input is text or not, so you can use it to process the file.
Afrow UK
25th May 2003 23:35 UTC
It's just outputting a load of numbers.
I need to get a line out of the file and search for ".pcx" in it
I just need to get hold of a line of text from it now...
-Stu
kichik
25th May 2003 23:40 UTC
Use:
IntFmt $0 "%c" $1
where $1 is the output of FileReadByte and you'll get the character read in $0. It's up to you to find out how to skip the non text part of the file, FileReadByte will read anything.
Afrow UK
25th May 2003 23:44 UTC
I shall look
-Stu
kichik
25th May 2003 23:46 UTC
[edit]heh, ok :)[/edit]
Then the byte read is a character that can not be displayed on screen, maybe 0. As I've said, it's up to you to tell where the text you want begins. Use FileReadByte to skip the parts you don't want, or can't read.
Afrow UK
25th May 2003 23:54 UTC
Ok, so I have tried to collect up 20 characters, and then search for .pcx in that:
loop_read:
ClearErrors
FileReadByte $R2 $R3
IfErrors error
IntFmt $R3 "%c" $R3
IntOp $R5 $R5 + 1
StrCpy $R4 $R4$R3
StrCmp $R5 20 0 loop_read
But $R4 comes out as only about 4 characters long.
What have I done wrong?
-Stu
Afrow UK
25th May 2003 23:55 UTC
Ok, It's not outputting spaces. At least I am getting part of the ".pc" in it!
-Stu :)
Afrow UK
26th May 2003 01:01 UTC
Here's what I made..
edited by kichik, attached below.
Works great on both md2 and sp2 files :)
-Stu
kichik
26th May 2003 15:08 UTC
Please attach large scripts.