#174088 - 2007-02-20 10:10 PM
Re: See if an UDF is loaded?
[Re: Lonkero]
|
masken
MM club member
   
Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
|

Well for me it's become clear when I've started working with KiXforms.
I know it might be bad structure to call UDF's from within UDF's, but that is what I have today. I want to keep my UDF's as standalone UDF's and that they work when called (ie, call their own dependencies), but that becomes hard when you're calling several of them from a form for example, and they have the same dependencies.
Reconstructing them so that the main script calls all dependencies is of course doable, but then one would still lack a good way to know why an UDF failed. If you could check within the UDF if a dependency is loaded or not, you could return a relevant errorcode and message saying this too 
I really like the idea of a function that reports loaded functions. Perhaps IsDeclared() could work so that if IsDeclared() is called without a name, it returns an array with all loaded vars and functions, and if called with a name, returns if loaded or not, like:
Syntax: IsDeclared("string", type)
Parameters:
string (optional) The variable or function you want to know the status of. If left out, all declared variables and/or functions are returned.
type (optional) 1 = variable 2 = function
?
Edited by masken (2007-02-20 10:12 PM)
_________________________
The tart is out there
|
Top
|
|
|
|
#174095 - 2007-02-21 11:03 AM
Re: See if an UDF is loaded?
[Re: masken]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I really like the idea of a function that reports loaded functions. Perhaps IsDeclared() could work so that if IsDeclared() is called without a name, it returns an array with all loaded vars and functions, and if called with a name, returns if loaded or not
There have been a few occassions when I'm doing something a bit tricky and I've wished that Ruud exposed the internal structures of KiXtart through automation objects, even if they were read only. Some of these have been addressed now with built-ins, but even so, I'd love to be able to code like:
$oKix=GetObject("KiXtart.Interpreter")
If Not $oKix.Features("IsDeclared()")
"Sorry, this script requires IsDeclared() to work correctly"+@CRLF
Exit 1
EndIf
For Each $oVariable in $oKix.Globals
"Global variable "+$oVariable.Name+" = '"$oVariable.Value+@CRLF
Next
For Each $oVariable in $oKix.Locals
"Local variable "+$oVariable.Name+" = '"$oVariable.Value+@CRLF
Next
For Each $oUDF in $oKix.UDF
"Defined UDFs "+$oUDF.Name+@CRLF
For Each $oParameter in $oUDF.Parameters
; Note, parameter will only have a value when inside the actual UDF.
"Parameter: "+$oParameter.Name+" value='"+$oParameter.Value+"' "+IIf($oParameter.Optional,"(optional)","(mandatory)")+@CRLF
Next
Next
For Each $oFD in $oKix.FileDescriptors
"File descriptor "+$oFD.Name+" is "
If $oFD.mode>=0
"in use, mode is "+$oFD.mode+" file path is '"+$oFD.Path
Else
"not in use."
EndIf
@CRLF
Next
"Currently executing line # "+$oKix.CurrentLine+@CRLF
myFunction()
Function myFunction()
Debug("Testing return stack enumeration")
EndFunction
Function Debug($s)
"DEBUG: "+$s"+@CRLF
" Return Stack:"+@CRLF
For Each $oReturn in $oKix.ReturnStack
" Calling entity: "+$oReturnStack.name+", line #"+$oReturnStack.line"+@CRLF
Next
EndFunction
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 558 anonymous users online.
|
|
|