Normal Topic FileExists() question (Long Winded) (Read 396 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
FileExists() question (Long Winded)
Jul 12th, 2005 at 5:58pm
Print Post Print Post  
I have a tab on a form that has lots of Check Box elements. Each check box represents a paper form that is a necessary part of a clients file. I have logic associated with the box that goes out to a directory using FileExists() and sees if the faxed document has been received and if it has it turns the box green, if not it turns box red to visually notify the user if the form is available.

This indicator is used in association with the user and a command button to @Asynchshell to a file viewer so a user can see the document when needed.

This form is used as a subform.

The logic below (for one box) is executed on form entry. It works as desired from the software point of view, however am I causing a problem for hardware by having it read the hard drive or network drive looking for 50 or 60 files every time a form is entered?

Also since this form is used as a subform I believe it thinks I am entering the form everytime the tab gets focus or loses focus.(the reason I believe this is because if I put a writeLn() statement in as commented out below it constantly activates)

Am I building a problem into my application. Is there a better way I should consider designing this feature?

I thought about only having it FileExists() if the element =1 however there still would be lots of activity and it would not deal with a file being removed.

All thoughts appreciated.

Thanks



// This checks to see if the PIO form is in the directory and puts a check mark in field element Ynpoi and turns box green or red for easy visual notification.

VAR VpoiYN as string



                 VpoiYN = ("c:\Images\poi\" + @str(propertyfirst+propertylast) + ".tif")
     


iF      FileExists(VpoiYN)
{
     YNpoi = 1
     @color(YNpoi,0,10)
     
}
else
{
     YNpoi = 0
     @color(YNpoi,0,12)
     // Writeln("cant find it")
}


  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FileExists() question (Long Winded)
Reply #1 - Jul 12th, 2005 at 7:11pm
Print Post Print Post  
Hello Robert

Looking to the hard drive more times then necessary is going to slow you down some. What you can do is use @Shell to do a dir and redirect the output to a text file. Something like this

Code
Select All
Var vSuccess as Int
Var vFile as String

vSuccess = @Shell("dir /B > listing.txt")
vFile = @Insert("listing.txt")
vFile = @Replace(vFile, @Newline(), ";")
Writeln(vFile) 



This will give you a StringArray of the files that are in the current working directory. You can then use FindStringArray() to see if a certain file is in that directory. If you need the files from another directory just change the dir to something like this and you will be good to go.

Code
Select All
vSuccess = @Shell("dir c:\Sesame\Data\Samples /B > listing.txt") 



Quote:
Also since this form is used as a subform I believe it thinks I am entering the form everytime the tab gets focus or loses focus.(the reason I believe this is because if I put a writeLn() statement in as commented out below it constantly activates)


When the tab gets focus the subform is going to get focus as it is the topmost element on that tab, I assume. What you can do is put another element on the top of the tab to get the focus so that the subforms form entry programming does not run every time you simply click on the tab.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged