Skip to content
⌘ NSIS Forum Archive

Searching through a file

10 posts

Afrow UK#

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
Afrow UK#
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#
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.
kichik#
[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#
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#
Here's what I made..

edited by kichik, attached below.

Works great on both md2 and sp2 files 🙂

-Stu
kichik#
Please attach large scripts.