Page 1 of 1

[Implemented] Make compiler constants as string available

Posted: Thu Jan 31, 2008 5:27 pm
by AND51
Hello!

It would be very fine, if you could make some numeric compiler constants available as string constants, too!
It's annoying to convert numbers to strings with Str().
But the main reason for this request is that this issue makes it imnpossible to create new constants when you have to convert numbers!

My idea would be, that you dublicate #PB_Compilrer_Line for example. The numeric version is still #PB_Compilrer_Line, the new string version would have a trailing '$':

Code: Select all

Debug #PB_Compiler_Line+1                 ; 1+1=2
Debug "Error in line "+#PB_Compiler_Line$ ; no conversion neccessary
Maybe you can realize this with other useful constants, too.
One numeric/float constant (without '$') and its string version (with trailing '$'). Currently, I only remember #PB_Compiler_Version, but you may add other constants that could fit this request.

This request already exists with the new-line-constants:
#CRLF is 9 (nine) and #CRLF$ is the real new-line-character.

// Edit:
You might also add #PB_Editor_*Count (by the way, these constants are not being auto-completed!).

Posted: Thu Jan 31, 2008 6:42 pm
by #NULL
just for fun :lol: :

Code: Select all

Macro mk2(CONST,VAL)
  #CONST = VAL
  CONST.s = Str(VAL)
EndMacro

mk2(foo,6)

Debug #foo+2
Debug ".."+foo

Posted: Thu Jan 31, 2008 7:07 pm
by AND51
Using this method I could stay regressive. I'd go on not being able to build constants and I would waste precious memory to unneccessary variables.
Just for fun, as you said.

Re: Make some compiler constants as string available, too

Posted: Thu Jan 31, 2008 8:39 pm
by PB
> #CRLF is 9 (nine)

Why should this be 9? It's two characters: CR and LF. And 9 is for tabs.

Re: Make some compiler constants as string available, too

Posted: Thu Jan 31, 2008 10:02 pm
by AND51
PB wrote:> #CRLF is 9 (nine)

Why should this be 9? It's two characters: CR and LF. And 9 is for tabs.
Sorry, I swapped something...
The correct example should be:
#TAB => 9
#TAB$ => " " (a real tab)

Re: Make some compiler constants as string available, too

Posted: Fri Feb 01, 2008 10:09 am
by PB
> The correct example should be:
> #TAB => 9
> #TAB$ => " " (a real tab)

They both already do this. I don't know what you mean?

Re: Make some compiler constants as string available, too

Posted: Fri Feb 01, 2008 10:36 am
by Dare
lol.

From #pb_number_1 to #pb_number_9223372036854775807, which gives us a positive quad's worth. Then the negatives. Then the floats. Then the hex renditions. Then the binary renditions.

Posting just for fun. :)