with all your help i have learned to print a selected message out of a string. first i store a series of messages only in a string. then i use a text statement like text(0,0,sub(str1,1,23)). when i fill all the 23 spaces with numbers like 12345678901234567890123 to fill the space. i use it to keep track oh the number of characters in a string. this works fine, but when i put spaces in place of my numbers and then reduce my number count by the number of spaces, i expected the remaining numbers to move to the right by the number of spaces i added up front. no deal.

the first thing i wondered, being a newbie, was the space character in ti connect different from what was in the calculator? so i tried it in the calculator. but it was the same.

centering is just a nice to have.

help would however be appreciated!

john
spaces take up only 1 pixel on the graphscreen
rthprog wrote:
spaces take up only 1 pixel on the graphscreen
Spaces are only a single pixel wide, while uppercase characters and numbers are 4 pixels wide, so you need four spaces to erase each character. Lowercase characters are a variable number of pixels, which can get confusing.
KermMartian wrote:
rthprog wrote:
spaces take up only 1 pixel on the graphscreen
Spaces are only a single pixel wide, while uppercase characters and numbers are 4 pixels wide, so you need four spaces to erase each character. Lowercase characters are a variable number of pixels, which can get confusing.


...which is why I would highly recommend that you (@jm) use the homescreen instead of the graphscreen.
is there a character which is four pixels wide which will not display like a space?
john massey wrote:
is there a character which is four pixels wide which will not display like a space?
Unfortunately no, sorry. Sad You just have to put four spaces for every non-space character (but don't forget that to erase past a space you only need a single space).
On the graphscreen, all characters take 4 pixels in width, 6 in height. Only exception is the space character, the exclamation mark, the comma, and the ' characters. The space is 1x6, the comma is 3x6, and the ' and ! are 2x6.

To center the text, you need to take and find out how many letters there are in that particular part of the string, then take that total and multiply it by 4.

Take the amount of spaces, and add that to the new total. check to see if there are any !, ', or , in there and add the appropriate amounts there as well.

Since there are 94 accessible pixels on the screen, you need to subtract your total from 94.

Let's say we have 'HELLO WORLD, I WIN!"

You have 14 letters, multiplied by 4, gives you 56. We have a comma there, gives you another 3, so now at 59. 3 spaces takes us to 62, and the ! makes it 64.

So 94 - 64 is 30.

Now, you need to divide that number by 2, and make sure you only get the iPart( of that number.

Like below:

BASIC Code wrote:
:ClrDraw
:"HELLO WORLD, I WIN!→Str0
:Text(0,0,Ans
:0→A:0→B:0→C:0→D
:For(F,1,length(Str0
:If inString("ABCDEFGHIJKLMNOPQRSTUVWXYZθ",sub(Str0,F,1
:A+1→A
:End
:Text(6,0,"LETTERS: ",A
:A*4→A
:Text(6,50,"PIXELS: ",A
:For(F,1,length(Str0
:If inString(" ",sub(Str0,F,1
:B+1→B
:End
:Text(12,0,"SPACES: ",B
:A+B→A
:Text(12,50,"PIXELS: ",A
:For(F,1,length(Str0
:If inString(",",sub(Str0,F,1
:C+1→C
:End
:A+(C3→A
:Text(18,0,"COMMAS: ",C
:Text(18,50,"PIXELS: ",A
:For(F,1,length(Str0
:If inString("!'",sub(Str0,F,1
:D+1→D
:End
:Text(24,0,"2 SPACE: ",D
:A+(D2→A
:Text(24,50,"PIXELS: ",A
:
:94-A→E
:Text(30,0,"PADDING: ",E
:
:iPart(E/2→E
:
:Text(36,0,"CENTERED: ",E
:
:Text(50,E,Str0
Generated by SourceCoder, © 2005 Cemetech


Granted, I know the program is bulky, but I am trying to make sure it is as simplified as possible to explain some stuff. And it does not have error checking, not that interested in the program. XD

I have this saved to 'My Projects' in source coder, but I don't recall how to let others see it.. *shrugs*
There is another faster way to do this, display a line of spaces to erase everything on that line then display the new line so that there is not as much computation as to how long each message is in pixels.
do what? o.O

The way I have this set up lets it be automated, and gives you the exact center of the screen. I have -no- idea what you are talking about by using spaces to compute the center of the screen. o.O
tifreak8x wrote:
do what? o.O

The way I have this set up lets it be automated, and gives you the exact center of the screen. I have -no- idea what you are talking about by using spaces to compute the center of the screen. o.O
I'm not positive, but I think Glenn may have missed the centering part and just focused on the erasing part.
lol, possibly XD

I am sure there is more to the original post, but with the way it was worded, I couldn't figure out much either.

The purpose of this thread was to figure out how to center text on the screen, right?
KermMartian wrote:
tifreak8x wrote:
do what? o.O

The way I have this set up lets it be automated, and gives you the exact center of the screen. I have -no- idea what you are talking about by using spaces to compute the center of the screen. o.O
I'm not positive, but I think Glenn may have missed the centering part and just focused on the erasing part.


Kerm is correct I had missed the centering part and was only thinking about the erasing.
first i want to thank you all for all your help. i wanted to do two things with this process (1) get the text near the center of the screen &(2) make the length 94 pixels so that i would not have to send the all spaces text command. why? i guess i thought it would be neat.

i followed tifreak8x's advice on how the center using the simple calculations. i will keep track of his program and perhaps i will use it later when you folks no longer classify me as a newbie. when i looked at LENGTH(STR1) i was surprised to see a number between 140 & 150 for the three messages. i learned in terms of string length i must count each number,letter, and space as one character. unlike the pixel count. in the sub command i need string numbers after all. if i have a 94 pixel message, what should be its string length? or is their no relationship?

thanks in advance

john
There is no real relationship, because it depends on each word length. At most, you can have 23 letters and 3 spaces, but of course you can have a certain combo of letters and spaces and fit in.

Easiest way is to paste what you want to appear at Text(0,0 and see if all of it shows up on the screen or not. *shrugs*

Also glad my program is useful to you. Took me like.. 15 minutes I think to write it. =]
to understand the code tifreak8x put into the "centering strings" post i want to get it and try it
well, I can try to post the program and screenshot of the program in use later when I get back. I can't seemingly access my server with my Vista machine, I need to download a decent FTP client I guess to do so. Anyways, for the time being, everything is above, that is the program in its entirety.

If you have questions on specific parts of the code, let me know, I will gladly help explain
Why don't you try using Text(-1, y,x, String instead? This way the text will be a.) much larger, b.) each character takes up the same # of pixels, and c.) much smaller/easier/potentially faster to erase.
hi tifreak8x,

i finally got the program running. my mac compiler had problems with spaces after a line of code. i did not know if there was a problem with two : at the beginning of a line so i took one of them out.

given that you could spend another 15 minutes and you can save me maybe several hundred hours in the next year would you be up expanding the scope of the program. what expansion you say?

WELLLLLL. you have a great program that has a single message in a string but i cannot call it because i do not know the length of the string. i guess that just means another line of code like text(60,0,length(str0 ? right?

it would be nice to make another loop outside the one you have written which would let the second loop pack a number(more than 10) of messages into a single string. then a second string with the lengths of all the strings in it.

i would appreciate it very much.

while i designed the central timing package for the Apollo space craft at 30 years of age, i am dyslexic. so sentence structure and spelling are very hard for me. by the way is their a SPELL CHECKER in this site some place! if you have problems understanding me, please ask! or if you suggestions on how better to communicate to the community please help yourself. i certainly never had pride of ownership of anything i have ever written!

AS ALWAYS, THANKS IN ADVANCE

john
rthprog wrote:
Why don't you try using Text(-1, y,x, String instead? This way the text will be a.) much larger, b.) each character takes up the same # of pixels, and c.) much smaller/easier/potentially faster to erase.


Down side to that is that you can't post as much text to the screen at one time as you can with smaller text. And if you use the smaller text, all text takes the same size in pixels, just stay away from the periods and such =p

Edit:

Soo.. you want the program to tell you how long the string is? That would be a matter of Text(36,0,"LENGTH: ",length(Str0

As to having more than one message, that wouldn't be too hard I suppose, just have a list that adds to the dimensions of the list elements as it finds a new message and can do a length of that section.

Is that what you are wanting to do?
john massey wrote:
hi tifreak8x,
by the way is their a SPELL CHECKER in this site some place!


Use a browser like Firefox or Google Chrome. Those have spell checkers built in. I'm pretty sure most other browsers do too =/
  
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 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