Computer Science Canada Turing for begginners |
Author: | 1337_brad [ Sat Jan 29, 2005 1:01 am ] | ||||||||||
Post subject: | Turing for begginners | ||||||||||
Well this tutorial is hot!!! w00t w00t! It is for anybody who is just starting out and would like to learn the basic commands =) Ok we will start with put and get statements. The put statement is to put a string to the screen, and it can be done in a few ways. 1:
2:
Pretty easy eh? =) Now the get statement. The simple get statement just gets user input from the keyboard, and puts it into a variable like so.
This simple code would get the users favorite color from their input. Now we can go on to loops =D. Loops are pretty much the foundation for any advanced program. Without them life would be a constant copy paste. First we will start with the basic loop, and exit when statement. A loop just keeps repeating a certain section of code until an exit when parameter is met.
This code just repeats adding 1 to the variable 'thenum' and puts it to the screen until it equals 10. You may have noticed that when I assigned the variable, I use ':=' instead of just '='. This is just how turing works, and if you don't put the collen before the equal sign when assigning a value to a variable, you will get an error. Now for one of my favorite things of all! The for loop! A for loop is just like a loop, but it has a finite number of times it runs. You start at a given number, and end at another given number.
This code does the same thing as the last loop did, but with much less coding required. When creating a for loop, you do not need to create the for variable (in this case it is i) turing declares it for you when it sees the for statement. Well this ends lesson one! :p I hope you have enjoyed my little intro to the basics of turing, and if you need further help with anything in turing whether it be really simple stuff, or really hard stuff, either just post in this topic, or post on the Help boards and I will be more than willing to help =D. |
Author: | Cervantes [ Sat Jan 29, 2005 8:13 am ] |
Post subject: | |
Thanks for the tutorial It would be better though if you explained what a string is and what an int is. Also, the first bit of code after you introduce the get command exits after the user inputs his answer. You should add a line put "Awesome! Your favorite colour is ", theanswer at the end, just so new programmers can see that it actually worked. Mind you, doing that would require a bit of explanation as to what that comma is doing there. +30 BITS Lastly, I wrote a tutorial soley on loops and for loops: it's rather in depth. For extra learning, check here. -Cervantes |
Author: | 1337_brad [ Sat Jan 29, 2005 4:26 pm ] | ||||||
Post subject: | Part 2: The Draw. series =D | ||||||
Ok guys, if you are interested in Animation, or graphical programs in Turing, here is the tutorial for you to get started!! There are lots of Draw. commands, I am just going to go over the basic ones and what they require. First of all there is the Draw.Line. The Draw.Line command is quite simple, and does just what it says, draws a line. The only parameters you need for this are x1, y1, x2, y2, color. If you don't yet know, Turing graphics are all based on pixels. x1,y1,x2,y2 are all positions within the run window, acording to pixels. For example, (10, 20), would be 10 pixels to the right of the bottom left corner, and 20 pixels up from the bottom. Anyway back to the Draw.Line command.
This code draws a black diagonal line from (10,15) to (20,30). To draw a verticle line, you would just have to make the two X values equal to eachother and only change the Y values Like so:
Too draw a horizontal line you just keep the Y values the same and change the X values like so:
Ok, sorry guys my mom needs the computer, I will continue this post very soon, and finish the Draw.'s =D |
Author: | quick flash [ Mon Feb 21, 2005 9:28 pm ] |
Post subject: | |
Thanks that was really useful, i have Gr.10 computer info sci and the tutorial isnt that great. |
Author: | ssr [ Mon Feb 21, 2005 10:08 pm ] |
Post subject: | |
dont forget u can do Font.Draw to change ur font, check out the turtoial section, or press F10 *** Im just saying this, 'cause I really dont like the default font in turing, Booo make ur program look bad.... |
Author: | HyperFlexed [ Wed Feb 23, 2005 10:09 pm ] |
Post subject: | |
ssr wrote: dont forget u can do Font.Draw to change ur font, check out the turtoial section, or press F10
*** Im just saying this, 'cause I really dont like the default font in turing, Booo make ur program look bad.... yes, but doing this disallows the use of Text.Locate making some simple programs a pain to make. I know this because I tried, and when I got assignments in compsci, I decided that it was fruitless to waste time on such a small issue. It is advantageous when the text background needs to be transparent though. |
Author: | seymournexus [ Fri Mar 04, 2005 11:21 pm ] |
Post subject: | |
var thenum : int loop thenum := thenum + 1 put thenum exit when thenum = 10 end loop don't you need to assign thenum to 0 first? o.O? |