![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I've made the following event that launch 'section.exe' to generate a value, but before I get the value, it process right away the 'fileOpen' after the shell command. With this, I could not get the right value. Code:
Sub Button1_click
Shell("section.exe")
FileOpen (c1,AppPath&"\SectionSelected.text",cRead)
lbsection.Text= FileRead (c1)
FileClose(c1)
End Sub
What is the right way?... or effective solutions? ![]() Thanks, Rioven
__________________
Rioven O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded) |
|
|||
|
Hi Cableguy, you got my point , I will try it...and again I've learned new things in a quick way. As a beginner and a limitted time (you can also say lazy
), I'm so greatful that members of this forum are very helpful. Thanks again Cableguy!
__________________
Rioven O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded) |
|
||||
|
Rioven,
You might also want to try using Sleep(2000), to wait for 2 seconds, instead of the Do While loop or alternatively add a count or timer in the loop so that your program doesn't hang if the file does not get created. You could then display a message to the user letting them know that there was a problem creating the file. Regard, RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD. Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD. "Defeat never comes to any man until he admits it."Josephus Daniels |
|
|||
|
Hi Randomcoder,
Thanks. yes. I thought a small delay is needed on cableguy's solution, because when file is created quickly, the DoEvents fires right away before the 'SectionSelected.text' file closes by section.exe and it causes an error because on the event it tries to open a file which is not yet close. I'm not really for delays.... You may have other suggestions? or ![]() while waiting... I'll also think of other workaround or strategies on my codes.
__________________
Rioven O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded) |
|
||||
|
I'm not for delays myself, but sometimes its the simplest solution.
Another option would be to catch the error and use a label to go back to trying to open the file. You could count how many times the program loops round and possibly throw up an error message if after say 6 attempts it still hasn't opened. There is probably other alternatives too ![]() Regards, RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD. Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD. "Defeat never comes to any man until he admits it."Josephus Daniels |
|
||||
|
Catching the errors here is not a good solution as there could be many many errors raised in that way.
I think that waiting using a sleep method should do the job. Maybe you should also check the FileSize so you want read an empty or incomplete file. Two applications could also communicate using the Network library and ip 127.0.0.1 but it will also require a Timer to wait for the data and it is much more complicated. |
|
||||
|
Erel has in many ways reiterated my previous statement...
Quote:
Regards, RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD. Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD. "Defeat never comes to any man until he admits it."Josephus Daniels |
|
|||
|
Thanks guys for your input.
I've tried the following code, I created a dummy control 'tb001' to trigger the file reading... Now it works...No overlaps or error on file reading. Is this code OK?? Code:
Sub Section_click
Shell("sectionProperty1.exe")
tb001.Focus
End Sub
Sub tb001_GotFocus
FileOpen (c1,AppPath&"\"&"SectionFileSelected.txt",cRead)
lbsection.Text= FileRead (c1)
FileClose(c1)
End Sub
__________________
Rioven O2 Atom life 624MHz, 1GB Internal ROM, WM6(upgraded) |
|
||||
|
Looks good to me, nice work around
![]() Regards, RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD. Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD. "Defeat never comes to any man until he admits it."Josephus Daniels |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing controls in runtime | Stanl3yCZ | Questions & Help Needed | 1 | 02-18-2008 02:51 PM |
| add menu item at runtime? | bob | Questions & Help Needed | 1 | 11-20-2007 11:05 AM |
| Runtime controls manipulation | Erel | Tutorials | 0 | 09-26-2007 01:18 PM |
| addlabel in runtime | tvrman | Questions & Help Needed | 2 | 09-04-2007 02:58 PM |
| Tab Simulation @ Runtime | anansath | Questions & Help Needed | 1 | 05-19-2007 02:55 PM |