This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
maggielwo


Newbie


Joined: 02 Aug 2009
Posts: 8

Posted: 02 Aug 2009 02:42:38 pm    Post subject:

I am making a basic RPG. At the beginning of it, the dude asks you what your name is. I stored that to a string. Now later in the game, I want to recall the string. The problem is that the string is often deleted by the user when they are just cleaning out their calculator. Is there any way to check if the string is there or not without there having an error in the program?
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 02 Aug 2009 05:37:36 pm    Post subject:

Here's an ASM program I used to use for that back in the day: http://www.ticalc.org/archives/files/fileinfo/303/30341.html
Back to top
Builderboy2005


Advanced Newbie


Joined: 19 Apr 2009
Posts: 51

Posted: 02 Aug 2009 05:54:04 pm    Post subject:

You could also store it in a list, which are much more program-friendly, in that you can check to see if they exist/have been altered or not.
Back to top
mr. sir


Newbie


Joined: 21 Feb 2008
Posts: 41

Posted: 06 Aug 2009 12:43:02 pm    Post subject:

Do you mean using a converter, or storing the string directly as a list? I tried the second one, and it worked, but how do you get the name from the list?
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 06 Aug 2009 01:50:47 pm    Post subject:

too bad you are going pure basic. CelticIII has a good library for instances like this. It's perfect for RPGs.

Anyhoo, welcome to UTI, Maggie.
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 06 Aug 2009 02:26:37 pm    Post subject:

mr. sir wrote:
Do you mean using a converter, or storing the string directly as a list? I tried the second one, and it worked, but how do you get the name from the list?

You can't get the name from a list using pure basic.
You would have to convert it using inString.
Back to top
Builderboy2005


Advanced Newbie


Joined: 19 Apr 2009
Posts: 51

Posted: 06 Aug 2009 03:56:06 pm    Post subject:

ztrumpet wrote:
You can't get the name from a list using pure basic.


Sure you could. Just in a roundabout manner :)

String to number conversion:


Code:
Input Str1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ->Str2
0->A
For(F,1,length(Str1
100A+inString(Str2,sub(Str1,F,1->A
End


This code converts a 7 character string into a single number A, which can then be put into a list. For names with more than 7 characters, just use 2 elements and 2 strings.

Number to string conversion:


Code:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ->Str2
":->Str1
While A
.01A->A
sub(Str2,100fPart(Ans),1)+Str1->Str1
iPartA->A
End
sub(Str1,1,length(Str1)-1->Str1


This code converts the number A back into a 7 character String. If you need more characters than what is available with only the alphabet, all you need to do is add on characters to the end of Str2. It doesn't matter in what order they are in, as long as the 2 strings in the two programs are the same.

You can store a string directly to a list, but that isn't what you want. What that does, is that you can store expresions such as "L1+L2"->L3, and then whenever you acces L3, it will return the sum of L1 and L2
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 06 Aug 2009 04:23:17 pm    Post subject:

Builderboy2005 wrote:
ztrumpet wrote:
You can't get the name from a list using pure basic.


Sure you could. Just in a roundabout manner Smile
I ment if it was list LABC then you couldn't get ABC. (Just a little misunderstanding... ) :)

Builderboy, I like your method, but you might want to add:
Builderboy2005 wrote:
If you need more characters than what is available with only the alphabet, all you need to do is add on characters to the end of Str2.
Str2 can have up to 99 characters in it.
Back to top
Builderboy2005


Advanced Newbie


Joined: 19 Apr 2009
Posts: 51

Posted: 06 Aug 2009 05:09:58 pm    Post subject:

ztrumpet wrote:
I ment if it was list LABC then you couldn't get ABC. (Just a little misunderstanding... ) Smile

Ah, yes thats true. But if you were the one creating the data, you wouldn't need to find out what the name was, since you created it!

ztrumpet wrote:
Builderboy, I like your method, but you might want to add:
Builderboy2005 wrote:
If you need more characters than what is available with only the alphabet, all you need to do is add on characters to the end of Str2.
Str2 can have up to 99 characters in it.


Oops, your right! :blush: yeah only 99 chars, and that should be plenty.
Back to top
mr. sir


Newbie


Joined: 21 Feb 2008
Posts: 41

Posted: 11 Aug 2009 03:19:54 pm    Post subject:

That's not what I meant. Say you have "ABC"→Str1. You can then do Str1→LDEF and not return an error. But when you access LDEF, you get an error.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 11 Aug 2009 04:02:50 pm    Post subject:

Still no way to get it back using Basic. What you're really doing is attaching a formula to the list. You get an error because there's no way to evaluate "ABC" to get a list, but the real problem is that you can't do anything to the formula except evaluate it.
Back to top
Graphmastur


Advanced Member


Joined: 25 Mar 2009
Posts: 360

Posted: 11 Aug 2009 07:37:10 pm    Post subject:

So why can't you do expr("Labc"?
Back to top
Builderboy2005


Advanced Newbie


Joined: 19 Apr 2009
Posts: 51

Posted: 11 Aug 2009 10:32:06 pm    Post subject:

Graphmastur wrote:
So why can't you do expr("Labc"?


thats the exact same thing as just executing Labc. Once you store a string to a list, there is no way to recall the string in any way, because the string isn't acting like a string, it is acting like a formula.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement