Turing/Help
Welcome to the Turing help desk. Have a question? Feel free to ask it here, and somebody will try to answer your question promptly.
In what situations does Turing really work great ?
[edit | edit source]- 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 [[Embedded Systems/PIC ?
- 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. #sorrynotsorry 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 high school 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.
passing parameters
[edit | edit source]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)
increasing and decreasing a counter by an increasing and decreasing amount??
[edit | edit source]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 instead 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)
It's going a+0, a-1, a+1, a-1, a+1 because -1**1=-1, -1**2=+1, -1**3=-1, -1**4=+1...etc. Try:
var y : int var z : int for x:1..10 y:=x z:=x put "a+", y put "a-", z end for
Slowing Down Your Program
[edit | edit source]How can I slow down the rate at which my program outputs(put) information to the screen? Please help! Urgent!
Answer:
- 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 one second before executing the next line. -Frazzydee|✍ 22:53, 6 Jun 2005 (UTC)
how do you skip lines
[edit | edit source]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)
GOLF SIMULATION ASSIGNMENT
[edit | edit source]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 don't 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 things such as if he /she is a amateur or pro golfer, therefore affecting how close their shot will be to the hole. Can anyone PLEASE send me a program that will do this. I am in HUGE need. THANKS!
Hi! Please tell me why this code does not work in turing. it crashes
[edit | edit source]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 triangle" 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 put "Please enter the 2nd length of the triangle" 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
Centering Text
[edit | edit source]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)
Exercises
[edit | edit source]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)
strings
[edit | edit source]outputs a word and determines if the centre word is an uppercase or lowercase?
why won't it out put my inputed word!! after it's been altered
[edit | edit source]if choice = 3 then loop put "title" %---use quotations---% 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
Making A RPG Game In Turing
[edit | edit source]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 extremely limited programming tool/language, making an RPG with level ups and weapons 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 programming language to use would be Java maybe, or C++, I really do not recommend the use of Turing to create a complex game such as the one you describe
I have made a simple (it has levels atk etc.) text based rpg but it is hard to make graphics in my game so instead I want 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
connect four
[edit | edit source]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. 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.
Mastermind
[edit | edit source]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 experimentor box blink
I know it
[edit | edit source]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
Answer:
- := 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)
A chat program, with a GUI
[edit | edit source]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 just wanted to know like i understand the how the loops work but I don't 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 have 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 don't 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?
Linking
[edit | edit source]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 (at least 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 every time. 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.
Too many Variables.
[edit | edit source]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. e.g. 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hello, while I won't Tudor you, you may find it helpful to look up arrays in the turing reference.
var sampleArray1: array 1..9,1..9 of int %Creates an array
var sampleArray2: array 1..3,1..6 of int: %Creates an array and assigns puts values into the array
=init(1,1,1,1,1,1, 1,1,1,1,1,1, 2,2,2,5,6,2)
sampleArray1(1,3):=6 %Assigns the integer 6 to index 1,3 of the array
I hope this helps :)
HELP!
[edit | edit source]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
Answer
- You are not using boolean properly. Rewrite (p1 = "p" or "P") to (p1 = "p" or p1 = "P"), so the first line would be:
if ((p1 = "p" or p1 = "P") and (p2 = "p" or p2 = "P")) then put "\nTie game, nobody wins."
Turing help
[edit | edit source]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.
Process and Procedures
[edit | edit source]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!!
problem with strings
[edit | edit source]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
Answer:
- Not sure what is what your are trying to do in the problematic section. My guess is that you would need to change the problem area into the following:
var allRight : boolean := true for i :1..4 if GUESS(i) not= ANS(i) then allRight := false end if end for if allRight the put "Correct" exit end if
Polygon
[edit | edit source]I am doing this assignment and i need to move a polygon but i don't no how so can u please tell me how. thanks so much
clear the screen after making the polygon, then just make the same polygon right next to where it was
It probably has something to do with getch and the follow mouse procedure try looking those up and once you know how to use getch you will probably figure it out
parallel port
[edit | edit source]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) doesn't do anything. use it like a variable, ex. "put parallelget"
programming alphabetically
[edit | edit source]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?
Base converter (base 2, 8, 10, 16 conversions)
[edit | edit source]hi!
i was wondering if i could get some help in converting numbers
i need to convert decimal, hexadecimal, binary and octal into each other
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 ==> why not just convert binary string back to integer (base 10) first? Then you can use "intStr(int, 0, <base>) to convert to Hex or Octal string?
decNumberOut := strint(binStringIn, 2) octalString := intstr(decNumberOut, 0, 8) hexString := intstr(decNumberOut, 0, 16)
character movement
[edit | edit source]BETTER QUESTION: How do you do WASD or Left Right Up Down without gravity, more specifically how do you move UP AND DOWN? There is no site with this info and I am starting to lose my mind.
Here is the code so far:
Text.ColourBack (green) cls setscreen ("graphics:800;800,offscreenonly,nobuttonbar,title:SPEEDY SNOWMAN") var x, y : int x := 100 y := 100
var keypress : array char of boolean
Text.ColourBack (green) cls
loop Input.KeyDown (keypress)
if keypress (KEY_RIGHT_ARROW) then x := x + 5 end if
if keypress (KEY_LEFT_ARROW) then x := x - 5 end if
drawfilloval (300 + x, 200, 50, 50, white) drawfilloval (300 + x, 260, 40, 40, white) drawfilloval (300 + x, 100, 80, 80, white) drawfilloval (280 + x, 270, 5, 5, black) drawfilloval (320 + x, 270, 5, 5, black) drawfilloval (300 + x, 260, 5, 5, red) drawfilloval (278 + x, 248, 4, 4, black) drawfilloval (286 + x, 240, 4, 4, black) drawfilloval (298 + x, 235, 4, 4, black) drawfilloval (308 + x, 240, 4, 4, black) drawfilloval (318 + x, 248, 4, 4, black) drawfilloval (300 + x, 190, 6, 6, black) drawfilloval (300 + x, 210, 6, 6, black) delay (5) View.Update View.Set ("offscreenonly") cls end loop
- Alexiler