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

Username:   Password: 
 RegisterRegister   
 getcharS
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vexd




PostPosted: Fri Sep 12, 2003 8:08 pm   Post subject: getcharS

Hi, i started learning Turing yesterday and i was wondering if there is a command to retreive MULTIPLE chars, for example upto 2..or if there are work arounds, since i have to get a number that is 2 digits or maybe even 3 digits long, i cant tell and it has to do someting with it almost right away....thanks ALSO if anyone knows the C++ version of \n in Turing . Yes i could use " " but im just wondering if there is another way Smile also ANOTHER Q, is there a way to rotate pictures, besides having like 360copies? ok thx again.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Sep 12, 2003 9:29 pm   Post subject: (No subject)

you can use
code:

get num
put num

to input a number (or string) of any length (up to 256)

Turing automatically adds a newline character to the end of all string outputs using put. The issue arises when you *don't* want that newline character. In that case add .. at the end of the line as in
code:

put "my name is: "..
put "tony"


as for picture rotation - you still need to have 360 copies, but you can generate them in Turing using Pic.Rotate() function.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
AsianSensation




PostPosted: Fri Sep 12, 2003 9:34 pm   Post subject: (No subject)

1. please elaborate...You have a 2 or 3 digit number, than you can always use a int variable or something and get it as a number. Or you can make it a string, set the string size, and than use strint () to convert it to number...

2.
code:
put skip

will skip like 3 lines (I think it's 3, not sure). If you only want to skip 1 line, by using put, Turing automatically skips for you.

3. Pic.Rotate rotates pictures, but in essence, it actually generates bunch of new pictures...so you weren't far off when you said you needed all those pictures.
AsianSensation




PostPosted: Fri Sep 12, 2003 9:35 pm   Post subject: (No subject)

grr...

tony got there first...

Evil or Very Mad
vexd




PostPosted: Sat Sep 13, 2003 9:50 am   Post subject: (No subject)

nnonono

u know how getch, gets the character without you needing to press ENTER. it only gets 1 CHAR. so i was wondering if there is a command that lets you get 2-3 letters without pressing enter...im doing this:
when the user presses f, it asks for a number (2 digits suppose) and after 2 digits have been pressed it continues WITHOUT THE NEED OF ENTER.

the secon q was: is there a new line character in turing like VBCRLF in vb and \n in C++ ...yea put skip works, but whats the value of SKIP?
AsianSensation




PostPosted: Sat Sep 13, 2003 10:04 am   Post subject: (No subject)

I don't believe there is something like that in Turing, but then again, it could just be my ignorance. But most likely because Turing isn't that sophisticated.

you could use getch twice or three times.



code:
var digits : array 1 .. 3 of string (1)

loop
    if hasch then
        for i : 1 .. 3
            getch (digits (i))
        end for
        exit
    end if
end loop

for i : 1 .. 3
    put digits (i)
end for


that works, but then you need to set restrictions or whatnot to have the user input the correct data.
AsianSensation




PostPosted: Sat Sep 13, 2003 10:09 am   Post subject: (No subject)

and to answer the other question...

\n actually works in Turing, so the following would work in the same fashion.
code:
%put "To be", skip, "Or not to be"
%put skip

put '\n'
put "To be", '\n', "Or not to be"


'\n' is the exactly the same thing as skip, there are no difference.
Blade




PostPosted: Sat Sep 13, 2003 12:10 pm   Post subject: (No subject)

..... or you could try something like....

code:
var number : int
var getnum : string (1)
var storenum : string (5) := ""

put "Enter a number"
for i : 1 .. 3
    getch (getnum)
    put getnum ..
    storenum += getnum
end for
put ""
number := strint (storenum)



this sounds to me like what he wants... however you can check the length of a string using length() you can also use it to check the length of an integer, just remember to convert it using intstr()... ex
code:
var integer:int:=11
put length(intstr(integer))


just letting you know, if you do... good for you :: pats back::
vexd




PostPosted: Sat Sep 13, 2003 5:32 pm   Post subject: (No subject)

Hey, thanks for the help, I knew i could do it the other way but was just wondering if there were other ways...guess not. also (\n == 3*vbcrlf)!? or is it just me?
AsianSensation




PostPosted: Sat Sep 13, 2003 6:55 pm   Post subject: (No subject)

don't know VB...

but '\n' in Turing is equivalent to \n in C++

you see it output more lines because when you use

put '\n'

the \n part skips a line, and the put part skips a line, so it looks like you are skipping 2 lines and beginning on the third one.

but in reality, '\n' just skips one line. (by skipping line, I mean starting a new line, but I was too lazy to type all that out)
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  [ 10 Posts ]
Jump to:   


Style:  
Search: