Source language: Translate to:

FileList - FileLen

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

FileList - FileLen

Postby domino » Tue May 15, 2007 5:00 am

Maybe I`m having a mental block as I`ve must have used this routine a hunderd times before without problems....

I used FileList to get the names of some .jpgs (no problem)

Then I used FileWrite to create a text file (.txt) of this list. (no problem)
first
second
third
fourth

However when I used FileRead / FileLen on the text file
firstsecondthirdfourth

NB interprets them as as all being on one line without carriage returns.

What am I doing wrong?

Cheers
Dave
User avatar
domino
 
Posts: 275
Joined: Sat Apr 02, 2005 7:11 am
Location: Notts UK

Postby Horst Helfen » Tue May 15, 2007 5:45 am

Did you give a line number in your script? The syntax of the FileWrite command is
Code: Select all
FileWrite "file name" "line number" "data"
So you have to increase the line number after writing each item or insert a carriage return/line feed ([#13][#10])
Horst Helfen

Programmers don't die, they just GOSUB without RETURN.
User avatar
Horst Helfen
 
Posts: 100
Joined: Thu May 05, 2005 4:11 am
Location: Hamburg, Germany

Postby domino » Tue May 15, 2007 6:10 am

Thanks Horst.. I'll have another look, but I didn`t think I needed to as the FileList command should do this automatically... as indeed it appears to if I look at the text file in Notepad, TextPad etc.


I`m simply dumping the contents of the FileList result into a text file.... and I`m sure I`ve never had to process the variable before...
User avatar
domino
 
Posts: 275
Joined: Sat Apr 02, 2005 7:11 am
Location: Notts UK

Postby Gaev » Tue May 15, 2007 6:17 am

domino:

a) Start with ...
Code: Select all
FileList "*.jpg" "Files" "[myJPGFiles]"

b) [myJPGFiles] will contain the list of file names separated by carriage returns ... so first ...
Code: Select all
StrReplace "[myJPGFiles]" "[#13]" "[#13][#10]" "[myJPGFilesWithLineFeeds]"

c) Now you can save the contents of [myJPGFilesWithLineFeeds] with ...
Code: Select all
FileWrite "myJPGList.txt" "All" "[myJPGFilesWithLineFeeds]"


This should do it ... you can verify it by reading myJPGList.txt with notepad.exe ... each file name should be on a separate line.
User avatar
Gaev
 
Posts: 3736
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby domino » Tue May 15, 2007 7:25 am

Thanks Gaev - That did the trick

I tried a bit of StrReplace but left the [#13] out of replace what... Doh!
Can't remember having to perform these evolutions with FileList before, but it's been quite a while since I`ve done any serious NB'ing so maybe I did.
User avatar
domino
 
Posts: 275
Joined: Sat Apr 02, 2005 7:11 am
Location: Notts UK


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest