Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: Derbles on November 23, 2017, 02:52:09 am

Title: Convert Number to String
Post by: Derbles on November 23, 2017, 02:52:09 am
Hey Everyone,

Is it possible to convert a number into a string?

For example, I have the String: "You found # $s"

Now I'm trying to replace the # with a number and replace the $ with a string.

It's trivial to replace the $, but I'm having trouble a number such as 25 into a string (list of chars).

Any thoughts?

Thanks!
Title: Re: Convert Number to String
Post by: Sorunome on November 25, 2017, 08:48:48 am
Axe has you covered!

You can do something like

Code: [Select]
:Text "You found # "
:Text 25>Dec
Title: Re: Convert Number to String
Post by: E37 on November 25, 2017, 03:34:15 pm
If you need the number as a string you can:
Code: [Select]
:ClrHome
:Disp NUMBER >Dec
:Copy(L5, L1, 5)
:ClrHome
:0 -> {L1 + 5}
That will save the number as a string in L1. It doesn't have to be L1 it can be any string. If the number is less than 5 digits long the string will start with space. So if the number was 354 the string would be "  354". Notice that the string has 2 spaces before the number.

The copy function can be used to take a "screenshot" of the homescreen. Copy(L5, POINTER, AMOUNT) would copy the AMOUNT of characters from the homescreen to POINTER. All the code does is display the number and copies the first 5 characters of the homescreen which happens to be the number that was displayed.