[BASIC] Dynamically arrange lists

You know the problem: You want to type

For 1-> A To 5
{0}->List A

but you get a syntax error – so you have to think of another way, like

{0}->List 1
{0}->List 2
{0}->List 3
{0}->List 4
{0}->List 5

This is now no longer needed!

With a simple trick, you can avoid this!
Simply try this:

“1”->Str 1
{0}->List Str 1
You will see: it works!
So, let us continue thinking. We want to have a counter.
Ne0tux wrote a small and fast program that takes the variable ‘A’ and converts it to Str 1:

“”->Str 1
For 1->Y To 1+Intg log A
StrMid(“0123456789”,1+Int (10Frac (A/10^Y)),1)+Str 1->Str 1

I think everyone could write the program at him/herself, but possibly not that optimized šŸ˜‰ (If there’s something that can be optimized, please tell me.)

Now you can write
For 1->A To 5
Prog “~NUM2STR”
{0->List Str 1

Note: Don’t forget to save the variable Y because it’ll be erased during the progress.

  1. Very informative, nice post. šŸ™‚

  2. Nice post !But I think it's a bit too much, just to take the variable 'A' and convert it to Str 1.If I well understand, this shorter code do exactly the same :""->Str 1For 1->Y To 1+Intg log AStrMid("0123456789",1+Int (10Frac (Z/10^Y)),1)+Str 1->Str 1Next(Sorry for my bad english)

  3. Wow, that seems to be much better (it's shorter)!I didn't know how to handle "log" and "StrMid", so I couldn't use it.Perhaps I have a typo, but I always get "3".

  4. "log" is the logarithm mathematic function. You can found it on the calculator's keyboard.You can found "StrMid" in [SHIFT]->[PRGM]->[F6]->[F6]->[F1](Str)->[F6]->[F3](Mid).Maybe this link can help you : http://www.planet-casio.com/Fr/forums/topic12049-1-Mettre-une-variable-dans-une-ch%C3%AEne-de-caract%C3%A8re.html#87876

  5. Ok, I will look on Wikipedia about log.I now replace my function by this one!

  6. Yeah, log is pretty useful… take a look at modulo as well, if you aren't already familiar with it. šŸ˜‰

  7. Modulo is a function I know. You need it in c very often.

  8. OK, log shouldn't be to difficult for you to understand then, its related to modulo in some ways. šŸ˜‰

  1. No trackbacks yet.

Write comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: