Hi Michael
How about a intellisense script?
I've wrapped up an example for the typecheck. It defaults the type of a var
to the 2nd char in the varname. You can take it from here when seeing an 'i'
as 2nd char (making the typecheck 'N' and adding an extra assert line with
the INT(var) = var check
Regards,
Sietse Wijnker
<intellisense script>
Type: 'U'
Abbrev: 'vas' (variable assert)
cmd: '{}'
data:
LPARAMETERS oFoxcode
LOCAL lcIndent, lcVarName, lcReturn
lcIndent = STRTRAN(RTRIM(oFoxCode.FullLine), oFoxCode.usertyped)
lcVarName = _CLIPTEXT
lcReturn = ""
IF EMPTY(lcVarName) OR GETWORDCOUNT(_CLIPTEXT) <> 1
lcVarName = INPUTBOX("What variable?", "ASSERT GENERATOR")
ENDIF
IF NOT EMPTY(lcVarName)
lcType = UPPER(SUBSTR(lcVarName,2,1))
oFoxcode.valuetype = "V"
TEXT TO lcReturn TEXTMERGE NOSHOW
<<lcIndent>> ASSERT VARTYPE(<<lcVarName>>,.t.) = '<<lcType>>'
MESSAGE 'General Error - Stop and investigate!' + Chr(13) + 'Variable
(<<lcVarName>>) not valid type.'
ENDTEXT
ENDIF
RETURN lcReturn
</intellisense script>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Michael Hawksworth
> Sent: donderdag 27 juli 2006 12:36
> To: [EMAIL PROTECTED]
> Subject: Checking variables and #Defines
>
> I use assert checks throughout my code, in fact I try to
> check variables and parameters religiously (unfortunately my
> grasp of religion must be patchy).
>
> One common check is of the type...
>
> Assert Vartype(liValue,.t.) = 'N' Message 'General Error -
> Stop and investigate!' + Chr(13) + 'Variable (liValue) not
> valid type.'
> Assert int(liValue) = liValue Message 'General Error - Stop
> and investigate!' + Chr(13) + 'Variable (liValue) not INT (Probably)'
>
> (Yes I know the message is daft but it helps to stop me just
> continuing through them thinking they are assert .f. lines
> that I use all over.)
>
> To save the typing I was looking at using #defines to
> automate the lines but you can't enter variable in the
> #defines to expand out. This leaves coding them in or using
> a global object to test the values (I use this for critical
> code sections in the live systems just to make sure anyway)
> but this adds to the overheads especially even if you check
> on call if you are in dev mode (.lDevMode = Version(2) = 2)
>
> Can you think of a better way?
>
> --
> Michael Hawksworth
> Visual Fox Solutions
>
> [EMAIL PROTECTED]
> www.foxpro.co.uk
>
>
>
>
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.