you can see from the program i want to nest or stack labels. that is call a single text command out of a group.


Code:
ClrHome:ClrDraw:CoordOff:GridOff:AxesOff:ZStandard
Full
For(I,1,3
Lbl 1
Text(0,0,"THIS IS MESSAGE 1")
Lbl 2
Text(7,0,"THIS IS MESSAGE 2")
Lbl 3
Text(14,0,"THIS IS MESSAGE 3")
Goto I
If I=1
Text(21,0,"THIS IS MESSAGE AFTER LOOP 1 ")
If I=2
Text(28,0,"THIS IS MESSAGE AFTER LOOP 2 ")
If I=3
Text(35,0,"THIS IS MESSAGE AFTER LOOP 3 ")
End
Not sure why you'd use a For loop. The same can be achieved using a string and subString( Smile
comicIDIOT wrote:
Not sure why you'd use a For loop. The same can be achieved using a string and subString( Smile
Hold on, don't get carried away with optimizations, let's solve his problem first. John, if I understand correctly, you want the output to appear in this order, correct me if I am wrong:

THIS IS MESSAGE 1
THIS IS MESSAGE AFTER LOOP 1
THIS IS MESSAGE 2
THIS IS MESSAGE AFTER LOOP 2
THIS IS MESSAGE 3
THIS IS MESSAGE AFTER LOOP 3
KermMartian wrote:
comicIDIOT wrote:
Not sure why you'd use a For loop. The same can be achieved using a string and subString( Smile
Hold on, don't get carried away with optimizations, let's solve his problem first. John, if I understand correctly, you want the output to appear in this order, correct me if I am wrong:

THIS IS MESSAGE 1
THIS IS MESSAGE AFTER LOOP 1
THIS IS MESSAGE 2
THIS IS MESSAGE AFTER LOOP 2
THIS IS MESSAGE 3
THIS IS MESSAGE AFTER LOOP 3
If you look at the If commands, it'd be more like

Quote:
THIS IS MESSAGE 1
THIS IS MESSAGE 2
THIS IS MESSAGE 3
THIS IS MESSAGE AFTER LOOP 1
THIS IS MESSAGE 1
THIS IS MESSAGE 2
THIS IS MESSAGE 3
THIS IS MESSAGE AFTER LOOP 2
THIS IS MESSAGE 1
THIS IS MESSAGE 2
THIS IS MESSAGE 3
THIS IS MESSAGE AFTER LOOP 3
But the "goto I" is an odd thing to toss in. I think John figures the calculator would read "I" as a variable and jump to the approriate Label (1,2,3)
Right, but I don't think that's what he wants to do. Wouldn't you agree that that is unnecessarily redundant? I assume he wants to perform 3 loops, do something in each loop, and print something before and after each iteration.
Agreed. I just feel the way he's gone about doing this is awkward.

John, have you had success using this model? What exactly are you trying to achieve? Do you need help or are you posting a technique that works for you?
comicIDIOT wrote:
Agreed. I just feel the way he's gone about doing this is awkward.

John, have you had success using this model? What exactly are you trying to achieve? Do you need help or are you posting a technique that works for you?
Ohh, I think I see what he's trying to do. I think with the "Goto I" he wants to go to Lbl 1, Lbl 2, or Lbl 3. Jon, that won't work, you need to do a conditional branch, like:


Code:
:ClrHome:ClrDraw:CoordOff:GridOff:AxesOff:ZStandard
:Full
:For(I,1,3
:If I=1:Then
:Text(0,0,"THIS IS MESSAGE 1")
:Do other stuff here for Iteration 1
:End
:If I=2:Then
:Text(7,0,"THIS IS MESSAGE 2")
:Do other stuff here for Iteration 2
:End
:If I=3:Then
:Text(14,0,"THIS IS MESSAGE 3")
:Do other stuff here for Iteration 3
:End
:
:If I=1
:Text(21,0,"THIS IS MESSAGE AFTER LOOP 1 ")
:If I=2
:Text(28,0,"THIS IS MESSAGE AFTER LOOP 2 ")
:If I=3
:Text(35,0,"THIS IS MESSAGE AFTER LOOP 3 ")
:End
KermMartian wrote:
Ohh, I think I see what he's trying to do. I think with the "Goto I" he wants to go to Lbl 1, Lbl 2, or Lbl 3.
Exactly Smile

comicIDIOT wrote:
I think John figures the calculator would read "I" as a variable and jump to the approriate Label (1,2,3)
comicIDIOT wrote:
KermMartian wrote:
Ohh, I think I see what he's trying to do. I think with the "Goto I" he wants to go to Lbl 1, Lbl 2, or Lbl 3.
Exactly Smile

comicIDIOT wrote:
I think John figures the calculator would read "I" as a variable and jump to the approriate Label (1,2,3)
My apologies, reading comprehension fail. Since we've been chattering on to each other, perhaps we should wait and see what John has to say. Smile
KermMartian wrote:
My apologies, reading comprehension fail.
Not your fault; I edited my post just seconds before you posted yours.
Quote:
Since we've been chattering on to each other, perhaps we should wait and see what John has to say. Smile
Sounds like a deal!
Kerm martin aka comicIDIOT and others have shown the exact output i am trying to accomplish. i explained this in a long post i made last night but somehow it got lost. in summery in each pass of the big loop (30 to 50 loops) these few lines of code are in, i want to select a Lbl number for up to 10 different messages by storing the message Lbl number in a "user created list". for example when a kid get the correct answer to a math problem he gets a "that a way to go kid" message. it would be boring to use the same message each time little billy got a correct message or even to give the "that a way to go kid" messages in the same order. with this method if i had 50 loops i could randomize 10 numbers 50 times (outside the program) and store the values in my "user created list". i guess the question becomes, do i have any chance of doing this? or is this just a bad dream? sorry for not being clearer!

i love your site and your responses javascript:emoticon('Very Happy')

THANKS A BOUNCH

john
You mean to randomly select a message that hasn't been shown already? Don't store the list, just generate it each time.


Code:

:ClrHome
:{0-->L1
:For(N,1,10
:-1
:Repeat prod(L1-Ans
:rand(1,10
:End
:Ans-->L1(N+1
:End
://So far, I've just created a randomized list in L1 containing each # 1~10 once, and 0 in L1(1).
:For(N, 1, 10
://Do Whatever Here...
:L1(N+1 -->I
:if I = 1:"Message 1
:if I = 2:"Message 2
:if I = 3:"Message 3
:if I = 4:"Message 4
...(etc)...
:if I = 10:"Message 10
:Text(7N-6,2,Ans
:// you'll be much happier if you replace the preceding line with "Disp Ans".  Otherwise you'll get an error if have >8 messages, which in this case you do, and plus you'll also save a little memory
:End


"//" and anything else in the line that follows it is a comment. Do not put this in your code.

btw, don't use this random-list code if you're planning on 20+ entries. It gets exponentially slower as the number of entries grows.

oh, and also, sub( would let you make this a little more efficient, but it's probably more important that you write something that you understand clearly.


*EDIT*
btw, Kerm, you *could* jump to any label by defining them in a string, its just really not worth it =D All you need to do is use Celtic 2/3 and add the goto to the start of the program within some conditional, and then have the program call itself with that conditional satisfied. By the time the program closes, you just have to make sure that that conditional is false, so that the program can start normally again.


Code:
:if AppVarGoto=True
:Goto Label: //Celtic would be used to edit the Label called here.
:End
://Code
i studied strings and substrings a little. can i store multiple complete text statements in a string? when called will they run with no problem? each string would have the same length since it would allow previous messages displayed to be erased i.e. when i call the substring with sub(str1,here i would use a"user created list"(I)to select a substring from the string different for each pass of the big loop ,the length is a constant)

given that all variables are global and there will be lots more than 10, how do i deal with this? given that i am a newbie. my thinking is to set the string to 1 as i leave the program and input the string with minor variations in the next program?

i LOVE lots of comments. since my memory is in the tank. i,e, i will be 79 years old next month. i have problems using symbols for STO in a comment. i remind myself where to find the symbol in the catalog. previously i had tried the > symbol on the mac keyboard and other > symbols but i found the little devil under char>keyboard and i do not want to forget it. i have tried to use // and " with no success! i saw a discussion about using "while 0:this is where the comment goes:end"
the program compiler elves cannot see my comment. to date the issue
has not been a program. maybe when size becomes an issue i will be forced to reconsider

thanks for all your help

john
what you can do is have one big string. Then, you can call a specific section of the string using the sub( command. Thus, if you make each message the same length (including spaces), you can easily correlate a numeric value to a message. (In this example, each message is 9 characters long) This way you can have as many "strings" as you want, limited only by the calcs memory.


Code:
:"MESSAGE1 MESSAGE2 MESSAGE3 MESSAGE4 MESSAGE5 MESSAGE6 MESSAGE7 MESSAGE8 MESSAGE9 MESSAGE10MESSAGE11"-->Str1
:For(N,1,11
:Disp sub(Str1, 9N-8,9
:End


to recycle my last bit of code:


Code:
:ClrHome
:{0-->L1
:For(N,1,10
:-1
:Repeat prod(L1-Ans
:rand(1,10
:End
:Ans-->L1(N+1
:End
://So far, I've just created a randomized list in L1 containing each # 1~10 once, and 0 in L1(1).
:For(N, 1, 10
://Do Whatever Here...
:Disp sub("MESSAGE1 MESSAGE2 MESSAGE3 MESSAGE4 MESSAGE5 MESSAGE6 MESSAGE7 MESSAGE8 MESSAGE9 MESSAGE10MESSAGE11", 9L1(N+1)-8,9
:End


bit nicer, eh?

*EDIT* Why would you want to delete part of the string? and what do you mean by a user-generated list? Could you explain?

*EDIT2*
you can't use the Sto command like that. What are u trying to do exactly with STO in a "commented" line?
when i display a message i will need to get rid of the previous since i am only using the three lines of the graph screen for these comments while i use the rest of the screen to display one problem at a time. for a total of 14 problems per graph screen until i do a cleardraw and start over. all the screen variables for example for text statements to position a number, a + symbol, initial location for the answer with ? mark coordinates for a line statement, location of the answer are controlled by a user created lists. the question is what do you do when you run out of of L1 to L9 ect? well you use user created lists. let us say you want to place a number in a text statement at various locations. say further that you want the x coordinates in the text statement to start at 4 and index across the screen by 12 spaces the syntax for this is "{4,16,28,40,52,64,76}then the little error which can be found in my mac catalog under char>keyboard, followed by the little L symbol found under catalog as the first L. the rest of the characters up to five are up to the user. in this case i chose for the first 2 characters FX which stands for First character to be placed and X for X coordinates in the print statement. sort of an old mans shorthand. since i found that the lists can have up to 999 numbers i started with 001, this followed with (I) which selects the correct x location for the x variable location in the print statement. in summary.

{numbers of locations separated by commas}STO little L FX001(i).
with each successive pass of the loop the x coordinate in the text statement indexes from 4 to 16 to 28 ect.

hope this clears up your questions

thanks for your interest

john
oh, you mean custom list names. you can create new lists like that by just setting their dims, btw. for example


Code:
0-->dim(lLIST


will create a new list called LIST.


Anyways, nice! Good to hear that you're doing everything in the graphscreen! Its probably easier to do in the homescreen because of the text entry commands, but if you feel like writing your own, (and especially if you pair up with some asm libs such as xLib) the graphscreen can be much, much, much better looking =D
well i am working on your suggestions. as always i started with a simple program like this "text(0,0,"1234567890")"STO Srt1. the little program bombed because it did not seem to like the " marks the around the characters. i then tried ' but no dice. if this works i will see my string of numbers on the graph screen right? when i used ' to surround the list of numbers the program did not bomb but rather did not put my numbers on the graph screen. i concluded that without " marks around the numbers the program was not seeing a text statement.

any suggestions? i guess these little marks are called delimiters.

john
rthprog's right, it would be much easier to do it on the home screen, but kudos for you for being different.
john massey wrote:
well i am working on your suggestions. as always i started with a simple program like this "text(0,0,"1234567890")"STO Srt1. the little program bombed because it did not seem to like the " marks the around the characters. i then tried ' but no dice. if this works i will see my string of numbers on the graph screen right? when i used ' to surround the list of numbers the program did not bomb but rather did not put my numbers on the graph screen. i concluded that without " marks around the numbers the program was not seeing a text statement.

any suggestions? i guess these little marks are called delimiters.

john


I think one of your issues is that you are trying to store the result of a function with no return into Str1. I think a possible other is if you are putting the quotes around the text command in your program it will be an issue as it will think the command is part of a string (which I believe is not allowed). You were correct to use "" around the string, I believe that is the only token used to show that it is a string in TIBasic.
well lads & lassies i just now was waking from a a nap when a idea that works. in each case we know that are going to print something.soooooooo. we store our string messages ONLY. then our text command will be for example text(7,0,sub(str1,1,10) and when i run it low and behold it runs!!

but i can find the sub command in the catalog in ti connect but where are the str commands?
  
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
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement