I was playing around trying to build a common UDF approach that could possibly be integrated into every UDF that would toggle "NoStringsInVars" and "Explicit" to "ON" for processing within the UDF and then if the option was not initially set turn it back off before the UDF exits.

The initial attempt is below. I found it interesting that the variable $Explicit is never caught as undimensioned in the initial usage. I would have thought that the UDF setting to "Explicit" would have occurred prior to placing the previous setting into the that variable $Explicit in the line:
code:
$Explicit = UDF_SetOptions("Explicit")  

Is this approach of interest to anyone else?

Is the KiXtart parsing engine working as one would expect with regard to the $Explicit variable?


$a = PadStr("401","0",8)
? "a=" + $a

Exit 1


Function UDF_SetOptions($a, optional $b)
; $a = "ASCII" or
; "CaseSensitivity" or
; "DisableDebugging" or
; "Explicit" or
; "HideCursor" or
; "NoVarsInStrings" or
; "WrapAtEOL"

; $b = "ON" or "OFF"

if vartypename($b) = "Empty"
$b = "ON"
endif
$UDF_SetOptions = SetOption($a, $b)
EndFunction

;FUNCTION PadStr($Input,$Pad,$Length)
;
;AUTHOR Howard A. Bullock (habullock@comcast.net)
;
;ACTION Left pad or Right pad a string with specified characters.
;
;SYNTAX PadStr($Input,$Pad,$Length)
;
;PARAMETERS $Input (Required) - String value
; $Pad (Required) - String value
; $Length (Required) - Integer (Max length of padded string)
; $PadSide (Optional) - String [L|R] Default is "L"
;
;REMARKS The $Pad can be one or more characters. If the Padding exceeds
; the specified maximum length then the resulting string is trimmed
; preserving the original data.
;
;RETURNS String
;
;DEPENDENCIES KiXtart 4.02
;
;EXAMPLES PadStr("401","0",8) result "00000401"
; PadStr("401","0",8,"R") result "40100000"
;
Function PadStr($Input, $Pad, $Length, optional $PadSide)
Dim $i, $x, $NoVars

$Explicit = UDF_SetOptions("Explicit")
$NoVars = UDF_SetOptions("NoVarsInStrings")
$PadStr = ""
$Input = "" + $Input
$Pad = "" + $Pad
$Length = 0 + $Length
If $PadSide="" or Len($PadSide)>1 or Instr("LR",$PadSide)= 0
$PadSide = "L"
Endif

$x = Len($Input)
For $i=$x to $Length - 1 Step Len($Pad)
If $PadSide = "L"
$Input = $Pad + $Input
Else
$Input = $Input + $Pad
Endif
Next
If $PadSide = "L"
$Input = Right($Input, $Length)
Else
$Input = Left($Input, $Length)
Endif
$PadStr = $Input
$NoVars = UDF_SetOptions("NoVarsInStrings", $NoVars)
$Explicit = UDF_SetOptions("Explicit", $Explicit)
Exit 0
Endfunction
_________________________
Home page: http://www.kixhelp.com/hb/