Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Grr... stupid put command things
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Blade




PostPosted: Wed Mar 19, 2003 7:37 pm   Post subject: Grr... stupid put command things

for some reason i cant get my strings to move over, when i want them to, but the integers will ! Sad i dont know of any other way to do this though...
as an example

code:

put "crap":20


what i'm trying to do is read 5 names, from a file, 5 marks, and 5 addresses and line them up in a table

as an example

John 123 Fake St. 86
Bill 45 Valley Ave 34

and so on...

but for some reason, i cant get strings to move over, and all that's readable from files are strings...
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Mar 19, 2003 7:43 pm   Post subject: (No subject)

i donno... works for me. It adds extra spaces AFTER the string though.

code:

put "":round(maxcol/2 - length("tony")/2), "tony"


that would put "tony" right in the center of the screen.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Asok




PostPosted: Wed Mar 19, 2003 7:48 pm   Post subject: (No subject)

You need to calculate the correct variable for :x x is not always equal to 20 it is equal to 20 minus the characters before so everything starts on the same line.
Blade




PostPosted: Wed Mar 19, 2003 7:56 pm   Post subject: (No subject)

well i think it still should move over, its not doing anything

edit:
haha i figured it out
Vicous




PostPosted: Thu Mar 20, 2003 11:11 am   Post subject: (No subject)

strings and numbers are aligned different, strings will put the extra spaces to the right, numbers put extra spaces to the right eg.

put "Hi":20,"bye"
gives you 18 spaces (20-# of letters)

Hi__________________bye

var number:int:=10
put number,"Bye"

gives you 18 spaces, the number 10 followed by the word bye

__________________10Bye

I hope this explains it
P.S. 1 underscore (_) equals 1 space, the forum edits out extra spaces
Blade




PostPosted: Thu Mar 20, 2003 11:32 am   Post subject: (No subject)

yea thanks, i was playin around with it and i figured it out... numbers have extra spaces before them, whereas strings have extra spaces after them Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: