Turing/Help
From Wikibooks, the open-content textbooks collection
Welcome to the Turing help desk. Have a question? Feel free to ask it here, and somebody will try to answer your question promptly.
Another way to get questions answered, likely more quickly, is to visit the highly active Turing help forums at compsci.ca, where members are quite happy to help you with your code.
[edit] In what situations does Turing really work great ?
- In what situations does Turing really work great ? When would I choose Turing over some other language on the Wikibooks:Programming languages bookshelf such as Programming:QBasic or Programming:Prolog or Python Programming ?
- Who uses Turing ?
- Are there any major programs written in Turing ?
- Can Turing run on my PC ?
- Can Turing run on my PIC ?
- Is there a GPL version of the Turing compiler/interpreter ?
- How do I install the Turing compiler/interpreter/IDE on my computer ?
i0 := --DavidCary 00:20, 4 October 2005 (UTC)
-
- Hi David. Sorry for the late response. Turing is used primarily as a learning tool, and was designed as such. Since it was made for ease-of-use rather than speed or versatility, the only reason you might use Turing is for a simple program, or if you're just getting started with programming.
- Mostly highschool students
- To my knowledge, no.
- Yes, turing runs on windows. It also runs on linux and mac.
- If you can get linux on it ;)
- Not that I know of, but I'm not sure.
- You'll have to buy a copy from holtsoft. If you are a student, and your school/board has purchased a license, you can get a copy for free.
- Under windows, installation is very simple. I don't use it that often and I haven't used it in a while, so I'm not sure if there are any important notes for installing it on other systems.
[edit] passing parameters
why is not passing parameters bad programming style? If it works without passing parameters, why not use global variables?
- The reasons may vary depending on the program. One of the most common reasons is that your procedures/functions may ultimately be included in a library, where people using your programs will want to just pass the parameters straight to it rather than figuring out all the variable needed. -Frazzydee|✍ 04:23, 24 May 2005 (UTC)
[edit] increasing and decreasing a counter by an increasing and decreasing amount??
So i need to increase a value by zero, then one, then -1, 2, -2, 3, -3... and i have no idea on how to do it. i've been trying to use some variation on
loop counter:=counter+1 a:=a+(-1)**counter end loop
but its just doing a+0 ,a-1, a+1, a-1, a+1 insdead of a+0, a-1,a+1,a-2,a+2 HELP!
- I'm not sure I completely understand your question...wouldn't that end up just equalling 0 if you're subtracting and then adding by the same number? -Frazzydee|✍ 11:58, 24 May 2005 (UTC)
[edit] Slowing Down Your Program
How can I slow down the rate at which my program outputs(put) information to the screen?
Please help! Urgent!
- Use delay(n), where n is the number of milliseconds you want the program to pause for. Example: delay(1000) will make the program pause for 1 second before executing the next line. -Frazzydee|✍ 22:53, 6 Jun 2005 (UTC)
[edit] how do you skip lines
is there any way you could skip a line under a certain condition
Example
if x=2 "now i need the computer to avoid the data from line 32 to 45"
- In most cases, you can just store it to a temporary variable in those lines:
var tmp : string
if x=2 then
for i : 1 .. 14
get : inp, tmp
end for
end if
- However, I've had cases where you can't store it to a variable at all, and I'm not sure how to get around that. If you find out how, please post it here! :) -Frazzydee|✍ 02:48, 9 Jun 2005 (UTC)
[edit] GOLF SIMULATION ASSIGNMENT
I am in grade 10, and we were just asked to make a simulation program. With variables such as wind, gravity, etc. Anyways, I've been sick for the past week or so and haven't got anything done because I dont have turing at my home. Can anyone send me a program which will simulate a golf shot? It has to have variables such as wind gravity slice and hook of the shot, and the user can enter thigns such as if he /she is a amteur or pro golfer, therefore affecting how close their shot will be to the hole. Can anyone PLEASE send me a prgram that will do this. I am in HUGE need. THANKS! my email is jamias_666@hotmail.com if u want to send me one. thank you!
u click enter
[edit] Hi i was wondering if you could tell me why this code does not work in turing. it crashes
procedure info (var base, height, L1, L2, L3 : int)
put "Please enter the base of the triangle" get base put "Please enter the height of the triangle" get height put "Please enter the 1st length of the triangle" get L1 put "Please enter the 2nd length of the triange" get L2 put "Please enter the 3rd length of the triangle" get L3
end info
procedure area (var b, h, Area_Triangle : int)
Area_Triangle:=b*h div 2
end area
procedure pmeter (var L1, L2, L3, Perimeter_Triangle : int)
Perimeter_Triangle := L1 + L2 + L3
end pmeter
procedure areapmeter (var finalarea, finalperimeter, Area_Triangle, Perimeter_Triangle : int)
put "The Area of the triangle is", finalarea, "The Perimeter of the triangle is,", finalperimeter finalarea := Area_Triangle finalperimeter := Perimeter_Triangle
end areapmeter
- You have redundant variables like b and base and you defined finalarea and final perimeter after the put. Get rid of the redundant variables and you should be fine:
%Declare the variables var base, height, L1, L2, L3, Area_Triangle, Perimeter_Triangle : int %Enter in values put "Please enter the base of the triangle" get base put "Please enter the height of the triangle" get height put "Please enter the 1st length of the triangle" get L1 NO BAGEL PENS. put "Please enter the 2nd length of the triange" get L2 put "Please enter the 3rd length of the triangle" get L3 %Display Area_Triangle := base * height div 2 Perimeter_Triangle := L1 + L2 + L3 put "The Area of the triangle is ", Area_Triangle put "The Perimeter of the triangle is ", Perimeter_Triangle
[edit] Centering Text
Could anybody tell me the different ways I can center text in Turing?
- Look up locate in the help file. You will need to know the length of the string to center it properly. -Frazzydee|✍ 03:32, 5 January 2006 (UTC)
[edit] Exercises
How do i write a program that allows the user to input any base 10 number then outputs the number into binary?
var tmp : int var tmpc : string := ""
get tmp
loop
tmpc += intstr(tmp mod 2) tmp := tmp div 2 exit when tmp=0
end loop
put tmpc
for decreasing i : length(tmpc) .. 1
put tmpc(i)..
end for
- This just keeps on dividing by 2 and recording the remainder, then it reads it backwards. Hope that helped, and sorry for the late response. -Frazzydee|✍ 03:48, 5 January 2006 (UTC)
[edit] strings
outputs a word and determines if the centre word is an uppercase or lowercase?
[edit] why won't it out put my inputed word!! after it's been altered
if choice = 3 then
loop
put title
put line
%setting outputs
locate (3, 1)
put "Enter a pattern:"
locate (4, 1)
put "Enter a pattern to substitute"
put "it with:"
locate (6, 1)
put "Enter a word to change:"
%getting inputs
locate (3, 18)
get pattA : *
locate (5, 10)
get pattB : *
locate (6, 25)
get word : *
if index (word, pattA) not= 0 then
loop
pos := index (word, pattA)
exit when pos = 0
beg_word := word (1 .. pos - 1)
end_word := word (pos .. *)
new_word := beg_word + end_word
word := new_word
end loop
end if
cls
put title
put line
locate (7, 1)
put word
end loop
end if
[edit] Making A RPG Game In Turing
Is it possible to make a RPG in turing? I can make a very basic battle system with hp and such. However I want to make it so you can level up and use items and all that. With a weapon making system of some kind.
Turing is an extrmely limited programming tool/language, making an RPG with level ups and wepons would be extremely difficult if not impossible. This is because Turing is used mainly as a learning tool for beginner programmers to show them the basic elements of programming, a better programmming language to use would be Java maybe, or C++, I really do not recommendd the use of Turing to create a complex game such as the one you describe
i have made a simple(it has levels atk ect.)text based rpg but it is hard to make graphics in my game so instead i wnt for a retro look if you like doing these kind of things you should go to this website.
http://compsci.ca/v3/index.php?pf=120&h=1&start=0
[edit] connect four
i need help writing a program for a video connect four game. i just had pneumonia and have missed 2 weeks or so of school. this project is due very soon and i'm not very good at turing. if somebody could please, please, please help me, that would be greatly appreciated. Thank you so much.
Of course you can make an RPG in Turing. Now, it won't be the graphical equal to Final Fantasy X, but you can make something that looks like a game from the Nintendo/Super Nintendo era without much trouble at all.
[edit] Mastermind
I need to create the game mastermind in Turing code for school. I am extremely lost and confused. I would deeply appreciate the code if someone has it or even just some general help. Thanks
how do I write a program that allows the user to click and make an LED light hooked up to a paper car, hooked up to an experimnetor box blink
[edit] I know it
What am I doing wrong, I know it but I can't remember?
case
label := "a"
put "no"
label := "b"
put "yes"
label := "c"
put "no"
label := "d"
put "no"
label := "e"
put "no"
end case
- := sets the value of a variable. You should be using = for comparison (eg. comparing the value of label to "a"). Try that, and come back if it still doesn't work...sorry, but I don't have time to test it myself right now :( -Frazzydee|✍ 22:58, 26 February 2006 (UTC)
[edit] A chat program, with a GUI
I've got 95% of the code complete. I'm stumped at the actual transfer of information though! I can open a connection, and connect, but I have no way of passing information between the server and the client! Can someone help?
- You should be able to use get and put, IIRC. Is there any reason why "get : ns, stringvar" won't work? (where ns is your netstream and stringvar is a string variable). If you're still having trouble, post your code somewhere and I'll take a look at it. -Frazzydee|✍ 23:00, 26 February 2006 (UTC)
umm yee i jus wanted to know like i understand the how the loops work but i dont understand how you get the program to loop so that it starts over again if the user prompts it to like for example.. in the case such as you hav the program run then you get to the end and you loop it so it says exit program if word = no( the user says no i dont want to play again) but how do you get it to start over if the user says yes they do want to start over again ??
[edit] Linking
I'm working on a turing project for school (grade 10 FTW), and I have to create a welcome screen to use in all of my programs. The problem is, I made a really nice one (atleast nice for what we've learned so far) but the code it really long. I don't want to have to copy that into the top of my program everytime. Is there a line of code that I can put into the top of each program to tell it to run the welcome screen first, then continue on to the rest of the program?
You can use include.
For example, if your welcome screen is in a file called welcome.t, you would write
include "welcome.t"
at the beginning of each of your assignments.
Make sure welcome.t is in the same directory as your assignment, though.
[edit] Too many Variables.
I am trying to make a Sudoku game, which has turned out to be a long script. Is there a way I could group variables together to make thing simpler. eg loop if a1 = {anyone of the Variable groups} then a1 := a1+1
== Hi, I was wondering if anyone could tutor me for turing 4.1.1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[edit] HELP!
Hey, can anyone tell me what the problem is with this code? It's a program for a rock paper scissors game.
var p1 : char var p2 : char var exit_char : string (1) var p : char var P : char
put "Note: The 'ROCK-PAPER-SCISSORS' game is meant for two (2) players. \nPress any key to continue. \n\n"
getch (exit_char)
put "Player 1, enter 'p' for paper, 'r' for rock, or 's' for scissors: ".. get p1 put "Player 2, enter 'p' for paper, 'r' for rock, or 's' for scissors: ".. get p2
if ((p1 = "p" or "P") and (p2 = "p" or "P")) then
put "\nTie game, nobody wins."
elsif ((p1 = "s" or "S") and (p2 = "s" or "S")) then
put "\nTie game, nobody wins."
elsif ((p1 = "r" or "R") and (p2 = "r" or "R")) then
put "\nTie game, nobody wins."
elsif ((p1 = "p" or "P") and (p2 = "r" or "R")) then
put "\nPlayer 1 wins, paper covers rock."
elsif ((p1 = "r" or "R") and (p2 = "s" or "S")) then
put "\nPlayer 1 wins, rock breaks scissors."
elsif ((p1 = "s" or "S") and (p2 = "p" or "P")) then
put "\nPlayer 1 wins, scissor cuts paper."
elsif ((p1 = "p" or "P") and (p2 = "s" or "S")) then
put "\nPlayer 2 wins, scissor cuts paper."
elsif ((p1 = "r" or "R") and (p2 = "p" or "P")) then
put "\nPlayer 2 wins, paper covers rock."
elsif ((p1 = "s" or "S") and (p2 = "r" or "R")) then
put "\nPlayer 2 wins, rock breaks scissors."
else
put "\nInvalid choice(s). Remember to enter only one letter; 'p', 'r', or 's'."
end if
[edit] Turing help
Can anyone help me, I need to make a scene where a cowboy jumps off a cliff onto his horse, and rides away. I can make the scene, but I cant seem to get the cowboy to jump down to the horse, and ride away. They are stick figures by the way, on a brown box.
[edit] Process and Procedures
I have a bunch of procedures and at the beginning of each i wanna put a music with a fork. i got it to work but it won't work inside the procedure because u cant' have a process in a procedure. what do i do? please help me!!
[edit] problem with strings
the following code is for a simulated game of mastermind. this is the basic code. unfortunately, i am having trouble with some of the strings and i've high lighted it... it says *****PROBLEM AREA****
var guess1, guess2, guess3, guess4 :string %guesses var ans1 :int :=Rand.Int (97,101) %generation of answer var ans2 :int :=Rand.Int (97,101) var ans3 :int :=Rand.Int (97,101) var ans4 :int :=Rand.Int (97,101) var nouveau_guess :int const ANS :string := chr (ans1)+chr (ans2)+chr (ans3)+chr (ans4) %answer
put ANS
%instructions put "Pick four of the following five letters: a, b, c or d \n"
loop %prompts put "Enter your first guess: ".. get guess1
put "Enter your second guess: ".. get guess2
put "Enter your third guess: ".. get guess3
put "Enter your forth guess: ".. get guess4
var GUESS :string := guess1+guess2+guess3+guess4 %guess
%answer completely correct if ANS=GUESS then
put "YOU WIN!" exit
end if
%evaluation of guess (completely correct) for i :1..4
if GUESS (i)=ANS (i) then
*****PROBLEM AREA***** i must convert the guess (i) into another character so that it doesn't check it again in the following code
put "Correct"
end if
end for
%evaluation of guess (sort of correct) for i :1..4
if GUESS (1) = ANS (i) then
put "semi-correct"
end if
if GUESS (2) = ANS (i) then
put "semi-correct"
end if
if GUESS (3) =ANS (i) then
put "semi-correct"
end if
if GUESS (4)= ANS (i) then
put "semi-correct"
end if
end for end loop
[edit] Polygon
i' am doing this assignment and i need to move a polygon but i don't no how soo can u please tell me how. thanks soooo much
it probably has somehting to do with getch and the follow mouse procedure try lookin those up and once you know how to use getch you will probably figure it out
[edit] parallel port
How do use the parallelget function. according to my understanding its more complicated than parallelget(64) . please answer in full detail as i am in g.12. what isBold text MOD and DIV. thanks . ALOT. parallelget is a function with no parameters:
procedure PGet(var val, i0, i1, i2, i3, i4: int) val := parallelget i0 := (val div 64) mod 2 i1 := (val div 128) mod 2 i2 := (val div 32) mod 2 i3 := (val div 16) mod 2 i4 := (val div 8) mod 2 end PGet
parallelget represents an already determined number, it requires no variables and that is wht parallelget(64) doesnt do anything. use it like a variable, ex. "put parallelget"
[edit] programming alphabetically
yeah, i need to make a program where i ask the user for two words, and then i put it in alphabetical order i have managed to do this by just making my variables word1, and word2, then i just put :
if word1 > word2 then
put word2,"":2,word1
else
put word1,"":2, word2
end if
in my program i did include the get statements and the variables... but i just put in the general idea i had for putting things alphabetically. The problem is, both words have to be either upper case, or lower case, i cant word1 as upper, and word2 as lower because lower case words are larger than upper even if the upper starts with "Z" and the lower starts with "a", my program will still display after the words are inputted, Z is before a. how do i make it so it says a before Z?
[edit] Base converter (base 2, 8, 10, 16 conversions)
hi!
i was wondering if i could get some help in converting numbers
i need to convert decimal, hexadecimal, binary and octal into eachother
i know that
binary_out := intstr (decimal_in, 0, 2)
will change decimal_in to binary_out
and for decreasing n : length (binin) .. 1
if binin (n) = '1' then
decout := decout + 2 ** (length (binin) - n)
end if
end for
will change the number back to decimal
i am having difficulty with : binary to octal/hex, octal to decimal/binary/hex, and hex to decimal/binary/octal
please help me! thanks
[edit] computer science
what is AB1 in computer science?
[edit] calculating tax for output
can anyone tell me how to make my program calculate tax? I already tried to multiply it by a number on the line itself, but my instructor does not allow it, saying it needs to be done as a variable, where after the price is inputed, you click and it calculates the tax.
Here is the program so far
var Name:string var Price:int var Total:int
put "What is the item you want to buy?" get Name:* put "How much does it cost?" get Price put "With tax, the total bill is.."
well it depends how much the tax is in your area, since i don't what it is in your area, I will prompt the user to input it just like they input the price. Below is the new program:
var Name:string var Price:int var Total:int var Tax : int put "What is the item you want to buy?" get Name:* put "How much does it cost?" get Price put "How much is the tax." get Tax put "With tax, the total bill is.." Total := (Price * Tax) + Price put Total
Thats it!, hope it helped
[edit] how to do square root
how do u do the square root in turing
-- i dont know that much about the Turing syntax, but maybe try raising it to the power of 1/2
like: n1/2
~John
- Sorry for the late response. You have two methods. Type 1) sqrt n or 2) n ^^ 1/2. You should try Computer Science Canada next time. --Mayfare (talk) 23:06, 4 January 2008 (UTC)
[edit] Write to file?
How exactly would you save info to a .txt from turing?
[edit] HELP!!!!
Please help! What are variable and value parameters? please include an example.
Thanks, utterly confused
ps. i love cake!
I am a grade 10 student who attends a "Computer Engineering" class. We have been doing Turing for a while now and we have been assigned a final project worth 30 percent of our marks. The assignment I was given is this:
You have been hired by the grade 10 Computer Science teacher to help students learn new computer terms by creating a Hangman game with the appropriate graphics. As a student enters a letter they think is in the word either a green LED light will light indicating the letter is correct or a red LED will light indicating the letter is wrong.
Peripheral: You must design and build a peripheral which will display 2 LEDs associated with attractively made designs for being correct (green) or wrong (red)
Interface: You must properly assemble a parallel port connector with 2 LEDs and insert them into the peripheral.
Now, I have created my hangman game on Turing with all of the game requirements, except for the peripheral and interface. Our teacher has not covered any of that information; therefore I don’t know how to do it.
Please, if you can explain to me or give me steps to what I should do (even a link to where I can get answers) will be very useful and very well appreciated. Thank you!
hello i am in grade 10. I tried my best to do this but i cant we are doing some practice on chapter 6 of turing and we have to creat a quiz where it ask's for like multiple choice questions,true and false and matching.This quiz consist of 10 questions. After each question the computer must chech if the answer is correct or incorrect, and output the result as well as the number of marks earned for that question. At the end of the test, the computer must print out the final mark for the test in 3 ways: example: 1.A fraction 2.A percentage 3. A letter grade If the test was a 50 percent or lower, the computer must ask if the student would like to re-write the test. If she/he wants to, the computer must loop back to the 1st question and begin again with a blank mark. The student can rewrite a total of 2 times Here are the 10 questions i want to put in order to make the turing program work Multiple choice question
1:What is another name for CPU Here are the options of the answer 1:Microprocessor put " Yes your right" 2:decode put "No try again" 3:execute put"No you're wrong" 4:Microchip put "Nope this is wrong sorry" So these questions i want to put into turing form
One question for true and false 1:Turing is a great programming language if the statement is true then put its right if the statement is false but its wrong
and other questions like this Please i really need help so please tell me ASAP
'how do we do fill in the blank on turing like i want to draw a small line for blank and then put the statement. like _________ is my name so how do i draw the line please helppp ASAPPPPP...'