PDA

View Full Version : File Search Path Progress


Bags
03-06-2006, 11:37 AM
Hi there, I just picked up the trial version of Autoplay 6. So far I like what I see although I have some issues.

First what I am trying to do is a File.Find function call with propper flags. I've searched though and found allot of examples but none seem to address the issue I have come across. Here is an example:

[inside a button click event]
fFile = "blah.exe";

sFile = File.Find(_SourceDrive, fFile, true, true, nil, nil);
if (sFile) then
for i, value in sFile do
Paragraph.SetText("Paragraph1", String.AbbreviateFilePath(value, 45));
-- do some more work
end
end

The above code works and displays the search progress in the paragraph object fine. You can see it going though the array and displaying each directory it looked in.
However, as soon as I write a function to handle the same thing and call the function from a button click event for instance, the progress does not display in the paragraph it just shows the fist directory in the array.

[inside button click event]
FindFile(_SourceDrive, "blah.exe");

[global function]
function FindFile(sPath, fFile)
sFile = File.Find(_SourceDrive, fFile, true, true, nil, nil);
if (sFile) then
for i, value in sFile do
Paragraph.SetText("Paragraph1", String.AbbreviateFilePath(value, 45));
-- do some more work
end
end
end

Any ideas why doing the same thing from a function call doesn't allow for the paragraph object to be updated?

Intrigued
03-06-2006, 04:43 PM
Reverse your thinking (call after the creation of said function)

-- global function
function FindFile(sPath, fFile)
sFile = File.Find(_SourceDrive, fFile, true, true, nil, nil);
if (sFile) then
for i, value in sFile do
Paragraph.SetText("Paragraph1", String.AbbreviateFilePath(value, 45));
-- do some more work
end
end
end


FindFile(_SourceDrive, "blah.exe");

Dermot
03-06-2006, 05:22 PM
That's what I was thinking Intrigued but then I noticed he had "-- global function" above the function which I took to mean the function was in the the Global Functions. It would not make sense to put a function in the Onclick of a button.

Intrigued
03-06-2006, 05:45 PM
But it will still work, if you code it the way I stated. I agree with you though. Global Functions area is where you should put the function code at and then 'call' it where you need it.

:yes

Bags
03-06-2006, 09:15 PM
Yes the function is in the global functions area and I call it from the click event of a button.

It does not show the progression through the array in the for loop, it just shows the first array value. Though if I copy paste the code from the function to the button click event space it works fine.

Eagle
03-06-2006, 09:19 PM
the action set.text removes any previous displayed text,
try adding functionality like strPara = Paragraph.get text
strParadisp = strpara.."\n"..then append the next 'data' to display in table cycle
paragraph.settext("paraObjectname", strParadisp);

--sorry dont have AMS6 open at the moment..

you would repeat the above for each cycle

hth a little

Bags
03-06-2006, 10:47 PM
Hey Eagle,

I rebooted my computer and now it works fine!? :huh

Don't know what that was about, thanks for the help anyway guys!

Eagle
03-06-2006, 10:58 PM
If that is all that was needed...whoopie :yes
(bit a puzzle - strange one)

Bags
03-07-2006, 01:58 PM
Yes it is very strange, although I've come accross this very same situation in Visual Studio 6 as well. Code was functioning well one night and the next it didn't do what it did before, reboot the machine and it was back to normal.

I don't know what causes it but it is an annoyance for sure because it causes allot of lost time debugging when there wasn't any need too. I blame it in XP.