Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
 
 
To
01/06/2001 21:17:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00514121
Views:
12
>Hitting someone with 100 lines of dense code isn't nice :-) Could you rephrase the logic with pseudocode?

Al,

Ok, let's try:
I have a function (or I thought today, better make it a form method, since it's called by a form), which allows me to modify structure (or only indexes) in our existing databases.

This function receives array of choosen databases for modification. Then I start my processing. The main loop is for all elements in the array of databases, the inner loop is by tables in each database. I have to check for existance of database (first loop: if database doesn't exist, I log a message and proceed with other databases - here I use loop operator). In the inner loop by tables I check, if the table could be open exclusively for possible changes, if not, a message is logged and I process next table. Modify_Structure program has quite complicated logic itself with bunch of scans or loops.

Now, I want allow user to terminate the whole process by hitting ESC. Not just terminate, but ask him: did he (she) really intend to cancel and if Yes, cancel the process, display stats and return back to the form. Answer "Yes" on this question sets oValid.lContinue property to false and I have to terminate.

I asked here question about temination of inner loops few months ago, and the answer, I got, I had to exit from each inner loop. So, I put
if !oValid.lContinue
    exit
endif
in each inner loop. This code works fine, but reading this discussion got me thinking, that it might be not the best approach. That's why I ask gurus like you or George to help me with advice.

Thanks again.

>
>IMO, ON ESCAPE should be used only to set a flag (e.g. llUserPressedEscape set to .T.), not branch to another bunch of processing. Doing that has the same effect as EXIT, LOOP or a GOTO.
>
>In complex logic, the action that must be taken on an ESCAPE-type event often differs depending on exactly what was going on at the time. Trying to support that with a global oValid.StopProcess can make it quite complex and hard to debug for all situations.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform