Page 1 of 1

File Scanning Problem

Posted: Thu Mar 19, 2009 6:30 am
by shadowslash
I made a program that does a scan of all the files in the computer... my problem is, i made a cancel button that supposedly cancels the scanning or stop it while it's currently running but somehow, i can't do that as the program (my program) just hangs up and the cancel button can't be clicked because my program is too busy with the scanning process... please help me out on how i can make my cancel button clickable in a manner that it can be clicked even if the program is too busy with the scanning process...

Posted: Thu Mar 19, 2009 9:29 am
by Mark
Hi Shadowslash,

You need to use send instead of a repeat loop, i.e. you need to learn how to write recursive functions. Here's a simple example.

You need a stack with two buttons and a field. Call the field "Simple Time Field".

Put the following into the script of the first button.

Code: Select all

--button 1
global gGoOn
on mouseUp
  if gGoOn is not true then
    put true into gGoOn
    send "foo" to me
  else beep
end mouseUp
Put the following at card or stack level.

Code: Select all

-- card or stack script
global gGoOn
on foo
  if gGoOn is true then
    put the long time into fld "Simple Time Field"
    send "foo" to me in 200 millisecs
  end if
end foo
and put the following into the script of button 2:

Code: Select all

-- another button
global gGoOn
on mouseUp
  put false into gGoOn
end mouseUp
Now, you should see the time appear in the field and being refreshed until you click the second button. The first button will beep if you click on it a second time, because you don't want to run this script in two different cycles next to each other --it would claim too much processing power eventually.

Exercise for the reader: make this with only one button ;-)

Best,

Mark

Posted: Thu Mar 19, 2009 4:18 pm
by shadowslash
um... i used the sample included with revolution (i think in the resource center) and i modified it a bit so that it checks each file if it matches any query in my virus database... (123 items currently) it uses the progress bar.. i still haven't tried the code yet but i'll get to it as soon as i finish my friggin Research Paper due monday.. man! it's tough dividing time with school and programming T_T