Originally Posted By: masken
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:
 Code:
$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