Page 1 of 1
Switch to force procedure output to a string...
Posted: Fri Sep 19, 2008 11:50 am
by DoubleDutch
A switch to force procedure output to a string could be pretty handy ($ could be appended to the procedure name).
eg:
Code: Select all
a=Len(x$) ; output is a number
b$=Len$(x$) ; output is a string
It could be ignored if the output is already a string (so Left( and Left$( would be identical).
A side effect is that syntax would be more compatible with traditional BASICS.
Posted: Fri Sep 19, 2008 4:38 pm
by blueznl
-1
Why?
Well...
Code: Select all
a$ = str$(len("-1000"))
a$ = len$("-1000")
I personally think it would just muddle up code, and I have enough problems as it is to keep my code straight

Posted: Fri Sep 19, 2008 5:39 pm
by DoubleDutch
It would be optional, you wouldn't have to use it = no muddle for you. lol

Posted: Sat Oct 04, 2008 3:23 pm
by PB
At first I couldn't work out what you wanted, then I realised you just wanted
a way to avoid using Str. So why not just make a macro for yourself? Example:
Code: Select all
Macro LenS(code)
Str(Len(code))
EndMacro
x$="123"
a=Len(x$)
b$=LenS(x$)
Granted, I know this means making a macro for every numeric command,
but you only need to do it once and stick it in a Residents file, and then it's
always there for you.
Posted: Sat Oct 04, 2008 4:02 pm
by DoubleDutch
Another advantage is that PureBasic syntax would become more compatible with standard BASICs, thus making it easier for newcomers to become familiar with.
Mid$(x$,2,3) would work the same as Mid(x$,2,3)
If this was extended so that any datatypes could override the output from a procedure then it would be even better. If its the same as the default datatype then no conversion, else the conversion could be added to the compiled code automatically.
eg.
Code: Select all
Procedure xyz.s()
result$="123"
ProcedureReturn result$
EndProcedure
z$=xyz()
x=xyz.l()
The default datatype being the one specified when the procedure was created.