View previous topic :: View next topic |
Author |
Message |
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1564
|
Posted: Thu Oct 09, 2003 11:27 pm Post subject: try, except, end |
|
|
Would like to see a way to capture errors similar to how in Delphi you can do -
try
{execute some code here}
except
{an error has occurred; do something or nothing}
end;
Where you can wrap your code in VDS with a TRY and attempt some code, if any error occurs it jumps to the Except section and runs code if any is there. |
|
Back to top |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Oct 10, 2003 1:47 am Post subject: |
|
|
I am not sure but I think Option errortrap does something similar ? _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Oct 10, 2003 7:58 am Post subject: |
|
|
Yeah, I use the OPTION ERRORTRAP myself.. In there, if I can't anticipate
a possible error, I offer the user the option of trying the operation over
again, or shutting the program down. Though I have had one problem with
that in one program..... The errortrap itself got caught in a perpetual loop
and had to be CTRL+ALT+DEL'd.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Oct 10, 2003 8:03 am Post subject: |
|
|
The biggest headache is once you call option errortrap :
It is not local to a sub/function.
You cannot switch it off either . _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Oct 10, 2003 9:41 am Post subject: |
|
|
CodeScript wrote: | You cannot switch it off either . |
Yes you can.
Code: | OPTION ERRORTRAP <blank> |
I use this all the time to provide try...except functionality. A true try...except wouldn't be possible in VDS because the language has no structure, any non-sequential of control has to be a command that branches to a label. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Serge Professional Member
Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Oct 10, 2003 9:51 am Post subject: |
|
|
good tip jules
serge _________________
|
|
Back to top |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Oct 10, 2003 11:07 am Post subject: |
|
|
Thanks for the Tip Jules. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
Vic D'Elfant Past Contributor
Joined: 26 Jun 2002 Posts: 673 Location: The Netherlands
|
Posted: Sat Oct 11, 2003 1:17 pm Post subject: |
|
|
Something like this would be cool to:
Code: |
<?php
$var = 'myvar';
switch($var)
{
case 'hello'
print "Hy folks!";
break;
case 'myvar'
print "Hello!";
break;
}
?> |
Vic _________________ phpBB Development Team |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Sat Oct 11, 2003 1:30 pm Post subject: |
|
|
Again, I achieve this sort of functionality by using a goto %%var with an option errortrap to handle the "else" option of %%var not equalling any label. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Oct 11, 2003 2:53 pm Post subject: |
|
|
Vic wrote: | Something like this would be cool to:
Code: |
<?php
$var = 'myvar';
switch($var)
{
case 'hello'
print "Hy folks!";
break;
case 'myvar'
print "Hello!";
break;
}
?> |
Vic |
Here it is...
Code: | %%var = "myvar"
if @equal(%%var,hello)
info Hy folks!
elsif @equal(%%var,myvar)
info Hello!
end |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Oct 11, 2003 3:11 pm Post subject: |
|
|
Here it is as some functions and commands:
Code: | rem --- Include this in your scripts... ---
#define command,switch,break
#define function,switch,case
rem --- Main script ----
%%variable = hello
rem Set the variable which will be 'switched'
switch %%variable
rem If the switched variable's value is 'hello', do this:
if @case(hello)
info "%%variable : hello"
end
rem If the switched variable's value is 'hi', do this:
if @case(hi)
info "%%variable : hi"
end
rem With the @switch() function you can get the value of the switched variable...
info The value of the variable which is switched : @switch()
break
exit
rem --- Include this in your scripts... ---
:Switch
if @unequal(%1,)
%%CaseValue = @trim(%1)
else
exit %%CaseValue
end
Exit
:Case
if @equal(%2,EXACT)
Exit @equal(%1,%%CaseValue,EXACT)
else
Exit @equal(%1,%%CaseValue)
end
:Break
%%CaseValue =
Exit |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
Back to top |
|
|
|