hi tifreak8x,

referring to your post and your program. i would like to be able to make a list of more than ten messages up in the top of you program where your single message is now. i would like it to pack all those centered messages into a single string. i would also like it to pack all the message lengths in a second string so that i can recover then after downloading them into the calculator. i.e. uploading to ti connect so that i can build my print library in ti connect.

will you help me

john
I would recommend putting lists of number (i.e. message lengths) into a list, that way you don't waste valuable strings and you can store and retrieve them easier.
Glenn wrote:
I would recommend putting lists of number (i.e. message lengths) into a list, that way you don't waste valuable strings and you can store and retrieve them easier.
I was just about to say the same thing. John, do you have any experience using lists? Just as strings are the correct storage item for variables made up for one or more characters, lists are the correct storage item for variables made up of one or more numbers. For example, a list can be {1}, {1, 2, 5, 1000}, {5, -2.5, 3.1415927}, or {1+2j, 4.1-9.1j}. Lists can be any arbitrary length between 1 and 999, inclusive.
i got a message from Kern Martin suggesting that i use strings to run my messages. i thought this would be the best way to keep all you helpers out their informed. I love strings! i use them to place all the numbers and number positions and short lines under each problem. i was going to extract the numbers from the second string and put them in two lists. one for start number and one string length.

thanks for the encouragement.

john
Oh, haha, I think that might have been an old message about your previous problem, but I guess it's applicable here too.
Might I suggest a list of lengths is unnecessary as start2 - start1 == length, and for the last one length(string) - start == length, this is a little more computation but if you have a lot of elements it will make up for that in memory savings.
i an effort to get more than one message in a string i did some things relative to tifreak8x's program he posted earlier.
1. removed all the text statements except the last one that displays the the centered message.
2. stored the centered variable(E) in a user-created list name called LE001(1).
3. made two copies of the program
4. changed the str number, message content and the LE001 reference for the first and second copies.
4. modified the 3 text statements to incorporate the LE001 reference.

the program runs fine as it prints out the centered messages in the last line in each copy of the code. it also runs fine as it executes the following code:
Str0+Str1+Str2→Str3
Text(32,⌊LE001(1),sub(Str3,1,⌊SL001(1)
Text(40,⌊LE001(2),sub(Str3,⌊SL001(1)+1,⌊SL001(2)
Text(48,⌊LE001(3),sub(Str3,⌊SL001(2)+1,⌊SL001(3)

except the final text message which it tries to print some of the second message.
i looked at Str3 in the calculator and it looks fine.

please help. i would happy to give you all the code if would help but i am just having problems with the last line of code.

john
If you could post the program as you have it in it's entirety and the text you are using to display, that would help and I can take a look at it and see what I think. However, I think it might be because you are going outside the length of the string for the end of str3, but I might be mistaken on that. I just need to see how everything is set up before being able to properly diagnose that problem.
here you go.


Code:

ClrDraw
"HELLO WORLD, I WIN!→Str0:0→A:0→B:0→C:0→D:0→E
For(F,1,length(Str0
If inString("ABCDEFGHIJKLMNOPQRSTUVWXYZθ",sub(Str0,F,1
A+1→A:End:A*4→A:For(F,1,length(Str0
If inString(" ",sub(Str0,F,1:B+1→B:End:A+B→A:For(F,1,length(Str0
If inString(",",sub(Str0,F,1:C+1→C:End:A+(C3→A:For(F,1,length(Str0
If inString("!'",sub(Str0,F,1:D+1→D:End:A+(D2→A:94-A→E:iPart(E/2→⌊LE001(1)
length(Str0→⌊SL001(1)
Text(0,⌊LE001(1),Str0
"GOOD!MATH IS POWER→Str1:0→A:0→B:0→C:0→D:0→E
For(F,1,length(Str1
If inString("ABCDEFGHIJKLMNOPQRSTUVWXYZθ",sub(Str1,F,1
A+1→A:End:A*4→A:For(F,1,length(Str1
If inString(" ",sub(Str1,F,1:B+1→B:End:A+B→A:For(F,1,length(Str1
If inString(",",sub(Str1,F,1:C+1→C:End:A+(C3→A:For(F,1,length(Str1
If inString("!'",sub(Str1,F,1:D+1→D:End:A+(D2→A:94-A→E:iPart(E/2→⌊LE001(2)
length(Str1→⌊SL001(2)
Text(8,⌊LE001(2),Str1
"KEEP DOING IT→Str2:0→A:0→B:0→C:0→D:0→E
For(F,1,length(Str2
If inString("ABCDEFGHIJKLMNOPQRSTUVWXYZθ",sub(Str2,F,1
A+1→A:End:A*4→A:For(F,1,length(Str2
If inString(" ",sub(Str2,F,1:B+1→B:End:A+B→A:For(F,1,length(Str2
If inString(",",sub(Str2,F,1:C+1→C:End:A+(C3→A:For(F,1,length(Str2
If inString("!'",sub(Str2,F,1:D+1→D:End:A+(D2→A:94-A→E:iPart(E/2→⌊LE001(3)
length(Str2→⌊SL001(3)
Text(16,⌊LE001(3),Str2
Str0+Str1+Str2→Str3
Text(32,⌊LE001(1),sub(Str3,1,⌊SL001(1)
Text(40,⌊LE001(2),sub(Str3,⌊SL001(1)+1,⌊SL001(2)
Text(48,⌊LE001(3),sub(Str3,⌊SL001(2)+1,⌊SL001(3)
There's massive optimization you could be doing there with code reuse so you only have to have one inString, loop, etc, but since TIFreak seems to be the point-man on this one I'll let him fill in the rest. Dan, if you are busy I'll try to get this optimized.
Yeah, I will mess with it tomorrow, not really up for coding tonight.
Kerm, i have not heard from Dan.

i have worked on your suggestions. but i am clearly in over my head.

do you have time to help me?

i would like to have over ten messages stored in one string and the message length stored in a user designed list with a name like ML001.

THANKS IN ADVANCE

john
john massey wrote:
Kerm, i have not heard from Dan.

i have worked on your suggestions. but i am clearly in over my head.

do you have time to help me?

i would like to have over ten messages stored in one string and the message length stored in a user designed list with a name like ML001.

THANKS IN ADVANCE

john


I would be happy to help, since it appears that no one is giving you any feedback. So all this program needs to do is randomly choose one of ten messages and center that message on the screen?
Hi Kerm,

It would be nice if you could make the number of messages a variable so that i could rerun the program and edit the existing messages and add new massages as i got smarter.

also it would be nice if the number of messages could be a variable and be more than ten.

the location of the message should also be a variable to either 0,7 or 14 for the Y value.

THANKS FOR YOUR ATTENTION TO MY PROBLEMS

john
Sorry, work has kept me extremely busy, and I have not really had the energy at night to work on it. I promise this is not forgotten, just very busy right now.. <<
Hi John, I've also been extremely busy, sorry for the lack of response. Rthprog, if you could jump in here, that would be quite helpful.
john massey wrote:
Hi Kerm,

It would be nice if you could make the number of messages a variable so that i could rerun the program and edit the existing messages and add new massages as i got smarter.

also it would be nice if the number of messages could be a variable and be more than ten.

the location of the message should also be a variable to either 0,7 or 14 for the Y value.

THANKS FOR YOUR ATTENTION TO MY PROBLEMS

john


so given y-location, randomly spit out a message and center it? I'll give it a whirl.
I of course recommend it take two args, an arbitrary string like "MESSAGE 1 HERE:THIS IS MESSAGE 2:CONGRATS, HERE IS THE THIRD ONE", and an integer Y-position. Shouldn't be too horrible, just count the delimiters, pick a random item, then center it.
see if this works =D L1 identifies the locations of ":" offset by one cell, L2 contains the centered-x-coordinates of each substring, and L3 will be a random, non-repeating list so that the order of messages is always different. You can always rename L1, L2, and L3 to whatever you want.


Code:

:":Message One:Message Two:Example Text:More Example Text:Even More Text:You Get The Idea:" -->Str1
:
://Following chunk finds all ":" in Str1, cell offset by 1. Follow above string syntax
:{1}-->L1
:1: While Ans
:Ans -->L1(dim(L1)+1
:inString(Str1,":", Ans+1
:End
:
://Finds "centered" x-coordinate for each substring
:{3,2,1,5,2,2,5,4,0}-->L6
:For(N,1,dim(L1)-2
:sub(Str1,L1(N+1)+1, L1(N+2)-L1(N+1)-1
:"seq(1+inString("fimstwz ", sub(Ans, X, 1)), X, 1, length(Ans -->L2
:sum(seq(1+L6(L3(X)),X,1, dim(L3
:iPart((94 - Ans)/2 --> L2(N
:End
:
://Generates psuedorandom list of non-repeating integers. Fastest algorithm I could think of. Once you've set your String1, you can run this program up to this point, delete the preceding code, and replace it by re-storing recalled values of L1, L2, and obviously Str1.  Theres no point calculating these values every time.  I'm sure others can help you with this.
:seq(X,X,1,dim(L1)-2 -->L3
:For(N,1, dim(L3
randInt(1, dim(L3 --> M
:L3(N -->A
:L3(M --> L3(N
:A --> L3(M
:End
:
://Whatever code you want.  I'm putting everything within a "While 1: Display Text: Pause: End" loop for now
:While 1
:
:ClrDraw
://Following chunk is what you need to display the text the "7" can be replaced with whatever y-coordinate you want.
:L3(L1(1
:Text(7,L2(Ans), sub(Str1, L1(Ans+1)+1, L1(Ans+2)-L1(Ans+1)-1
:L1(1) +1
:Ans - dim(L3)(Ans>dim(L3))-->L1(1
:
:Pause
:End
glad to see the site back up. THANKS FOR YOUR HELP. I had some little problems with your code. I am assuming that you are working on a PC but I am working on a Mac. My compiler will not tolerate spaces. Like at the end at the end of a line of code and other places. Your code had lots of them. Further it will not accept // to start a comment. The method I use with the "while 0: comment here:end" works fine but fails sometimes like when I put :end in a comment without putting " marks around it. Since I am using some of your variables I felt a need to clear out any of the stuff they held. I also had to replace your STO symbol and all your L1 like symbols with those on my TI connect catalog. Also my compiler puts in the : symbols automatically so I took them out. Lastly, i commented out the randomizing function to just get the code running. But it does not run. It gets stuck in a line of code that starts out "seq(1+inString and when the compiler rejects the code, the cursor ends up on the"i" in that little lower case text string.

DelVar Str1
" "→Str1:DelVar L₁:DelVar L₂:DelVar L₃:DelVar L₄:DelVar L₅:DelVar L₆:DelVar N
":Message One:Message Two:Example Text:More Example Text:Even More Text:You Get The Idea:"→Str1:While 0:Following chunk finds all ":" in STRING 1, cell offset by 1. Follow above string syntax:End
{1}→L₁
1:While Ans
Ans→L₁(dim(L₁)+1
inString(Str1,":",Ans+1
End
While 0:Finds "centered" x-coordinate for each substring:End
{3,2,1,5,2,2,5,4,0}→L₆
For(N,1,dim(L₁)-2
sub(Str1,L₁(N+1)+1,L₁(N+2)-L₁(N+1)-1
"seq(1+inString("fimstwz",sub(Ans,X,1)),X,1,length(Ans→L₂
sum(seq(1+L₆(L₃(X)),X,1,dim(L₃
iPart((94-Ans)/2→L₂(N
End
While 0:Generates psuedorandom list of non-repeating integers. Fastest algorithm I could think of. Once you've set your String1, you can run this program up to this point, delete the preceding code, and replace it by re-storing recalled values of L1, L2, and obviously Str1. Theres no point calculating these values every time. I'm sure others can help you with this.
seq(X,X,1,dim(L1)-2→L3
For(N,1, dim(L3
randInt(1, dim(L3→M
L3(N→A
L3(M→L3(N
A→L3(M
Whatever code you want. I'm putting everything within a "While 1: Display Text: Pause: End" loop for now:End
While 1
ClrDraw
While 0:Following chunk is what you need to display the text the "7" can be replaced with whatever y-coordinate you want.:End
L3(L₁(1
Text(7,L₂(Ans), sub(Str1, L₁(Ans+1)+1, L₁(Ans+2)-L₁(Ans+1)-1
L₁(1) +1
Ans - dim(L₃)(Ans>dim(L₃))→L₁(1
Pause
End
  
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 2 of 4
» 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