How to control error when using an unknown variable

97 views
Skip to first unread message

Alain Aupeix

unread,
Jun 29, 2024, 3:22:03 AM (4 days ago) Jun 29
to Harbour Users
Hi,

In my main prg, I declare buildate as memvar, and as public.

In a function, I have something like this line :

result=iif(buildate != NIL,"     Compilation : "+buildate+chr(10),"")

It works fine if the variable is defined as public. but I want, if the
variable isn't declared, to affect "" to result and continue without crash.

Is-it possible using this, and how ?

   #xcommand TRY              => s_bError := errorBlock( {|oErr| break(
oErr ) } ) ;;

                                 BEGIN SEQUENCE
   #xcommand CATCH [<!oErr!>] => errorBlock( s_bError ) ;;
                                 RECOVER [USING <oErr>] <-oErr-> ;;
                                 errorBlock( s_bError )
   #command FINALLY           => ALWAYS

Thanks
A+
--
------------------------------------------------------------------------
*Alain Aupeix*
Sites web : JujuLand <http://jujuland.pagesperso-orange.fr/> |
Pissobi-Lacassagne <http://pissobi-lacassagne.pagesperso-orange.fr/> |
Gadel <https://www.gadel-environnement.org/>
------------------------------------------------------------------------
X.ubuntu 16.04 | H.arbour 3.2.0-1 (r2023-12-07 19:00) | Hw.gui 2.23-5dev
(r3405) | G.ramps 5.1.2
------------------------------------------------------------------------

trepao2...@gmail.com

unread,
Jun 29, 2024, 12:58:57 PM (4 days ago) Jun 29
to Harbour Users


Perhaps:

IF Left(Type("buildDate"), 1) != "U"
    // Your code...
ENDIF


TYPE() Determine the type of an expression ------------------------------------------------------------------------------
Syntax TYPE(<cExp>) --> cType

Arguments <cExp> is a character expression whose type is to be determined. 
<cExp> can be a field, with or without the alias, a private or public variable, or an expression of any type.

Returns TYPE() returns one of the following characters:

TYPE() Return Values ------------------------------------------------------------------------
Returns Meaning --------------------------------------------------------------------

A Array 
B Block 
C Character 
D Date 
L Logical 
M Memo 
N Numeric 
O Object 
U NIL, local, or static 
UE Error syntactical 
UI Error indeterminate 

Alain Aupeix

unread,
Jun 29, 2024, 3:58:34 PM (4 days ago) Jun 29
to harbou...@googlegroups.com, trepao2...@gmail.com
Le 29/06/2024 à 18:58, trepao2...@gmail.com a écrit :
Left(Type("buildDate"), 1) != "U"

Works well ...

Thanks
A+
--

Alain Aupeix
Sites web : JujuLand | Pissobi-Lacassagne | Gadel
X.ubuntu 16.04 | H.arbour 3.2.0-1 (r2023-12-07 19:00) | Hw.gui 2.23-5dev (r3405) | G.ramps 5.1.2
Reply all
Reply to author
Forward
0 new messages