ASCII() statement equivalent in basic stamp?
Hello.
Other basic syntaxes have ASCII() statement, which returns apropriate ASCII char of statement supplied.
For example:
A=ASCII(33) equals to A="!"
How should I do this in BS2 ?
Need to create custom data type and do lookup each time?
Other basic syntaxes have ASCII() statement, which returns apropriate ASCII char of statement supplied.
For example:
A=ASCII(33) equals to A="!"
How should I do this in BS2 ?
Need to create custom data type and do lookup each time?
Comments
So, there's no ASCII() function because you can write a single character like "!" and it will be treated as a number like 33 or $21.
FOR A=32 TO 255
NAME$=NAME$+ASCII(A)
NEXT A
is impossible with basic stamp?
Then how to handle user input? say user inputs his name on keypad ?
There are some examples of such things in some of the Nuts & Volts Columns. Essentially, you declare a byte array long enough for the user name and write the code to input characters one at a time and store them as characters in the byte array, usually marked at the end with a zero byte. You run into difficulties with potentially long user names because of the limited variable storage on the BS2 (only 26 bytes total).
For long strings, you have two options ... You can use part of the program EEPROM to store the characters using the READ and WRITE statements. You're limited somewhat there because of the potential for the EEPROM to wear out with repeated writing. In practice with keypad / keyboard inputs, this doesn't happen since it takes a very long time to enter in over 100K keystrokes (the usual wear limit for an EEPROM location). Alternatively, you can use a different Stamp model that has additional RAM storage. The BS2p/pe/px models are best for this. This extra RAM is not directly usable for variables ... you use GET and PUT statements to access it.
I have a Synth keyboard, Yamaha PSR E-413, made in 2011. Quite sophisticated, with many many MIPS DSP and CPU. And with whopping 436kb(!) of user usable EEPROM, which is being accessed via emulated serial port via USB at 9600bps! Situation looks very similar to BS
Speaking seriously, are there even a small chances that string variables ever to be added?
The Propeller, on the other hand, has 32KB of memory that is shared between variables and compiled code. In addition to Spin, which has limited built-in support for string variables and lots of library routines to add additional functions, the Propeller can use C which has standard C libraries for strings. In both Spin and C, strings are implemented as byte arrays with zero-byte delimited strings.
The Propeller II, which is still under development, has much more memory (128K split into mostly RAM and a little bit of ROM) and speed and will also support Spin and C.
Running Z80 emulator means that I can upload a ZX Spectrum rom and...