Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on May 18, 2017, 06:49:06 AM
-
Hi Charles
In my translation of JimKsmall basic i forund that in PowerBasic
he use function name as Returned value
do i can leave this way ?
i know that FUNCTION = 1 in O2 work
also as RETURN variable
as exemple i show you this:
FUNCTION LookUp(S AS STRING) AS INT
Dim Counter AS INT
Dim MyStr AS STRING
MyStr=S
Counter=1
MyStr=UCASE(MyStr)
LookUP=SB_UNKNCOM 'DEFAULT VALUE
While MID(Table[Counter].Command,1,1) <> "*" And Counter < SB_NUM_CMDS
If TRIM(Table[Counter].Command) = TRIM(MyStr) THEN
LookUp = Table[Counter].Tok
Counter = SB_NUM_CMDS
End If
Counter++ '+1
Wend
End FUNCTION
is that ok ..because looks to me that function not respond ???
or i must do something like that:
FUNCTION LookUp(S AS STRING) AS INT
Dim Counter AS INT
Dim MyStr AS STRING
MyStr=S
Counter=1
MyStr=UCASE(MyStr)
FUNCTION = SB_UNKNCOM 'DEFAULT VALUE
While MID(Table[Counter].Command,1,1) <> "*" And Counter < SB_NUM_CMDS
If TRIM(Table[Counter].Command) = TRIM(MyStr) THEN
FUNCTION = Table[Counter].Tok
Counter = SB_NUM_CMDS
End If
Counter=Counter+1
Wend
End FUNCTION
-
Your second example looks correct. But I will see whether o2 can be persuaded to adopt the first style of function value return.
-
Yes, we can do it for functions, but not methods. I will post the update tomorrow.
function mul3(v as float) as float
mul3=v*3
end function
print mul3 14 '42
-
Hi Charles
that is fine
I still use old A041 version which work fine for me ..
so new update will be A043 right?