#202988 - 2011-08-26 06:31 PM
Non-Existing Function returns
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Ran into an interesting situation today...Should this return true? What is it returning? @Error still says 0.
If NonExistentFunction()
? "yes"
else
? "no"
endif
get $
|
Top
|
|
|
|
#202990 - 2011-08-26 07:14 PM
Re: Non-Existing Function returns
[Re: Björn]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Ha I know right. Me either... But been messing around with kix2exe, and trying to get it's built-in kixforms registration UDF to work.
http://kix2exe.ramonitor.nl/udfs.php#k2e_registerkixforms
From the site...
If $K2E_KixformsEnabled = True
If K2E_RegisterKixforms() = True
$System = CreateObject("Kixtart.System")
EndIf
Else
; code if K2E_RegisterKixforms() failed
EndIf That first line isn't always returning true like it should, so I tried removing it and just checking for UDF. But...That second line always returns true lol.
|
Top
|
|
|
|
#203037 - 2011-09-06 11:56 AM
Re: Non-Existing Function returns
[Re: ShaneEP]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
It's correct, if a little confusing when you know that:
- In KiXtart speech marks around strings are optional. Any string (in the role of a parameter) which is not recognised as KiXtart syntax is assumed to be a string.
- In KiXtart a non-zero length string is always true (even is it is "0")
So because the function does not exist in the KiXtart syntax dictionary it is assumed to be a simple string and as it is not null it's boolean value is true.
In your example even the word True is not a boolean, it is a non-zero string. If you replaced your True with False it would work exactly the same, which could be a bit confusing.
KiXtart does catch bare strings in some cases, which can also be a little confusing to neophytes, In the following example the first three work but the last does not:
""+Hello+@CRLF
CStr(Hello) @CRLF
"" "Hello" @CRLF
"" Hello @CRLF
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 370 anonymous users online.
|
|
|