hi,
there are no examples to find about the topics
FileFindFirst, FileFindNext
e.g., my files are:
0001.wpt
0002.wpt
0011.wpt
0015.wpt
so a file name pattern could be ????.wpt
1) can this file search pattern "????.wpt" be used?
2) how will NXC signalize
a) if any first file exists at all or not? (using FileFindFirst)
b) if yes: if any additional file can be found? (using FileFindNext)
c) if end of search has been reached? (using FileFindNext)
can anybody provide help?
NXC: use of FileFindFirst, FileFindNext ?
Re: NXC: use of FileFindFirst, FileFindNext ?
I'd rather use ListFilesType. This is the one I use in my NXTFileManager.
You may want to look at an example.
You may want to look at an example.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Re: NXC: use of FileFindFirst, FileFindNext ?
What 'm looking for is something as available by 2 Pascal procedures which work like
(I have been programming with Pascal for 10-20 years)
(using NXC sysListFiles (which I just discovered - thx muntoo!) I always get runtime errors, FileFindFirst/Next promises to be more easy to use I assume)
Code: Select all
FindFirst(path: string; attr: Byte; var S: TSearchRec)
FindNext(var S: TSearchRec);
Code: Select all
program FindFirstDemo;
var S: TSearchRec;
begin
FindFirst ('*.PAS', faAnyFile, S);
while DosError =0 do begin
WriteLn(S.Name);
FindNext(S);
end;
end.
Re: NXC: use of FileFindFirst, FileFindNext ?
Here's an example that I have just now put into the example files for the NXC help system.
You should not use ? for a wildcard character.
John Hansen
Code: Select all
task main() {
byte handle;
unsigned int result, fsize;
string fname = "*.ric";
result = FindFirstFile(fname, handle);
NumOut(0, LCD_LINE1, result, true);
int i=1;
while (result == LDR_SUCCESS) {
NumOut(0, LCD_LINE2, i, false);
TextOut(0, LCD_LINE3, fname, false);
Wait(1500);
// fname = "";
result = FindNextFile(fname, handle);
NumOut(0, LCD_LINE1, result, true);
i++;
}
CloseFile(handle);
Wait(3000);
}
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: NXC: use of FileFindFirst, FileFindNext ?
thank you very much John,
that's very handsome and quite similar to the Pascal syntax I'm used to!
Thx a lot!
ps:
[OT]
do you already know when you will publish the next Brcixcc/NXC release?
[/OT]
that's very handsome and quite similar to the Pascal syntax I'm used to!
Thx a lot!
ps:
[OT]
do you already know when you will publish the next Brcixcc/NXC release?
[/OT]
Who is online
Users browsing this forum: No registered users and 1 guest