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

Username:   Password: 
 RegisterRegister   
 What does procedure TextDelay do??
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Neja




PostPosted: Wed Jun 18, 2003 9:10 pm   Post subject: What does procedure TextDelay do??

Huh?
I have an interview where I have to define
code:
procedure Delay (strtext : string)
    for i : 1 .. length (strtext)
        put strtext (i) ..
        delay (20)
    end for
end Delay

Can anyone give me an extremly detailed description of it? I don't understand particularly why it's a procedure used as a variable....
Sponsor
Sponsor
Sponsor
sponsor
Mephi




PostPosted: Wed Jun 18, 2003 9:33 pm   Post subject: (No subject)

code:
procedure Delay (strtext : string)
    for i : 1 .. length (strtext)
        put strtext (i) ..
        delay (20)
    end for
end Delay


the procedure obviously declares it as a procedure
Delay is the procedures name
(strtext : string) is called a parameter in this case, it is the word/sentence that you want text delayed
for i : 1 .. length (strtext) is a counted loop this loop runs as many times as the length of strtext, the input
put strtext (i) the i changes as the loop progresses, thus this displays the letter that youre on, eg if its the first time, i = 1 thus the first letter of strtext is displayed
.. makes it so that all other letters will be placed on the same line
delay (20) is the time (in milliseconds) in between the display of each letter
end for ends the counted loop
end Delay closes the procedure

To use this, you would do:
code:
Delay ("Hello")

this would display the word Hello letter by letter with 20 milliseconds in between each letter
Blade




PostPosted: Wed Jun 18, 2003 9:34 pm   Post subject: (No subject)

its used as a procedure so if you want to use it more than once in your program you can call it instead of rewriting the code.... and the variable is used because if you want to use a different word, or different speeds in the delay you can change it... otherwise you cant
Neja




PostPosted: Wed Jun 18, 2003 10:06 pm   Post subject: (No subject)

Ah. Thank you. I've been using the code for my game alot, sad that I don't know what it is, eh?
Tony




PostPosted: Wed Jun 18, 2003 11:11 pm   Post subject: (No subject)

yeah, it might also be a good idea to give some credit for code you take from others Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
PaddyLong




PostPosted: Wed Jun 18, 2003 11:45 pm   Post subject: (No subject)

Neja wrote:
Ah. Thank you. I've been using the code for my game alot, sad that I don't know what it is, eh?


very. this is really basic code...
Blade




PostPosted: Thu Jun 19, 2003 11:35 am   Post subject: (No subject)

tony wrote:
yeah, it might also be a good idea to give some credit for code you take from others Confused


since it is very basic... i wouldnt call it stealing, but in this case he did cuz he didnt know what it did... like if i went and wrote one like this really quickly using Font.Draw i know other people have and it would probably look the same... but it doesnt mean i took it... but understand where yer coming from since he did tell us he took it
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  [ 7 Posts ]
Jump to:   


Style:  
Search: