I am having a problem with a return statement on the same line as previous program statement. For example the following script does not work:
' tryreturn.bas April 25, 2011
uses "console","os","file","dt"
dim utmp as string
setutxtmp("c:\thinbasic\utx2.tmp")
utmp=getutxtmp()
console_write "UTXTMP=" & utmp & $CRLF
console_waitkey
'==================== end of thinbasic script =================
function setutxtmp(text2 as string) as string
static utxtmp as string = "utx.tmp"
if(len(text2)>0) then : utxtmp=text2 : end if : return utxtmp
end function
function getutxtmp() as string
dim utxtmp as string : utxtmp=setutxtmp("") : return utxtmp
end function
'==============================================================
HOWEVER IF I MOVE THE FIRST RETURN UTXTMP (IN RED) TO THE NEXT LINE IT WORKS.
IS THIS A BUG?
' tryreturn.bas April 25, 2011
uses "console","os","file","dt"
dim utmp as string
setutxtmp("c:\thinbasic\utx2.tmp")
utmp=getutxtmp()
console_write "UTXTMP=" & utmp & $CRLF
console_waitkey
'==================== end of thinbasic script =================
function setutxtmp(text2 as string) as string
static utxtmp as string = "utx.tmp"
if(len(text2)>0) then : utxtmp=text2 : end if
return utxtmp
end function
function getutxtmp() as string
dim utxtmp as string : utxtmp=setutxtmp("") : return utxtmp
end function
'==============================================================
NOTE: In these functions I am trying to use static variables in functions to avoid global variables. It is also to make my thinbasic user library as close to my perl and
c language libraries for my test software applications.
Also if I cannot trust the use of : to separate program statements this can be
a problem for the users of my application(s) as users will also have to write thinbasic scripts patterned after the examples I will be providing.
If we can fix this bug it would help a great deal. Also it would make thinbasic more robust in the use of : to separate program lines.
Bookmarks