|
Post by johnno56 on Jan 14, 2022 19:48:11 GMT -6
I have in interesting conversion problem.
I found my ancient calculator program - sdlbasic - and figured I could cannibalize some of the code...
I came across the use of mid(). SDLBasic defines it as mid(string, start {,end}) ('end' is optional) (both mid() and mid$() can be used)
In the calculator program, mid() is used as, mid(a,2) (sdlbasic can define variables as a string (ie: a = "") but the sdlbasic documentation does not explain how this function works. Ok the number "2" indicates the start position of string "a", but does not explain in the absence of an "end" variable, how much of the string is extracted. I personally would assume it to mean from the 'start' to the 'end'... I could be wrong.
Has anyone seen mid() used in this way before? If so, how would I convert this? Without an "end", do I assume only 1 character, or all characters from "2" to the end of the string? My brain hurts...
I will attach the code for reference only... without the images and conversion it won't run...
Lines 205 and 211....
|
|
|
Post by aurel on Jan 15, 2022 4:40:36 GMT -6
in general i prefer to use mid$ or mid() so mid (string, start,..opt len) if opt len then probably is to end of string that should be ..even if is nnot a bug...
by the way ..how you test it?
|
|
|
Post by aurel on Jan 15, 2022 4:47:54 GMT -6
is this a problem if left(a, 1) = "-" then a = mid(a, 2, 1) else
or should be
if left(a, 1) = "-" then
a = mid(a, 2, Len(a))
|
|
|
Post by johnno56 on Jan 15, 2022 7:59:04 GMT -6
Thanks Aurel. I will try both methods on the sdlbasic version... just to see the effect... then I will convert the RCBasic version accordingly... Thanks for the tip.
|
|
|
Post by aurel on Jan 15, 2022 8:01:15 GMT -6
oh no i now figured that is given code .sdlbas i tried to compile it on rcbasic ...heh funny and again error console jump and gone
|
|
|
Post by johnno56 on Jan 15, 2022 8:20:44 GMT -6
No. Not that funny... I have done the same thing myself over the years... I get SO confused at times.... lol
|
|
|
Post by rosy on Jan 16, 2022 3:12:06 GMT -6
I would enter any number >= len (a), you can also try -1
|
|