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

Username:   Password: 
 RegisterRegister   
 Frequently Asked Questions (And Answers!)
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheOneTrueGod




PostPosted: Sun Jun 04, 2006 9:19 am   Post subject: Frequently Asked Questions (And Answers!)

THE TURING FAQ
(With Answers!)


Alright, these are some questions that (I've found) have been asked quite frequently, so I'm going to compile them into one message, and hope that people check here first.

Q: HW IE DO Ths PrGGY???????!!!?
Ans: Ugh... Alright, first of all, you need to learn how to type. Second of all, you need to use a descriptive topic title and post a detailed description of your problem, along with the relevant code that is causing you the problem. The code provided doesn't necessarily have to be your entire program, just enough so that we can either A) run it, or B) understand enough to help you.
Keep in mind as well, that this isn't so much of a request as it is a requirement. Read [The Rules], you'll notice that it is quite explicit about the netiquette involved in posting questions.


Q: Can someone please write this program for me?
Ans: No. It doesn't matter how much flattery you write, it doesn't matter how many of your limbs your teacher will chop off if you don't get the program done on time. We are not here to write programs for you, we're here to give help if you run into problems.

Q: Why isn't this working?
Ans: You need to debug your program. I don't mind doing some minor debugging, but I'm sure that everyone doesn't agree with me on this one, and I have my limits on how many programs i'm going to debug Razz So, I will try and impart some debugging techniques that I have picked up.

  1. put. Yes, put. If you output the variable in question, you can see its value, and therefore determine why the program isn't doing what you want it to do. This can also be used to determine which variable in a drawn-out if statement isn't declared, etc.
  2. break. This causes the program to stop at a certain point, and it allows you to then go through your program line by line. In Turing, it isn't that great alone, but when used with put, it becomes quite powerful. You output the stuff you want to know, then stop the program with break. This lets you see the data before it gets erased by a cls, or by other drawn stuff in your program. This will also let you see exactly what your program is doing, line by line.
  3. Turing has debugging tools. In the Turing window, go to Run -> Show Debugger Menu. Then go to the Debugger menu and go to Show Debugger Controls. You can use these controls to trace the execution of your program, line by line, slowly.


Q: Why is my program flickery?
Ans: You aren't using View.Set ("offscreenonly") and View.Update or you aren't using them properly.
The order of code should be as follows:
code:

View.Set("offscreenonly") % Make sure this is spelled EXACTLY as is.

loop
   % Draw your images before the View.Update
   %Notice this gap here.  DO NOT 'View.Update' WHILE you are drawing.  'View.Update' AFTER you are done drawing.
   View.Update
   % delay (preferably using Time.DelaySinceLast)
   cls
end loop

If "offscreenonly" is not spelled right, it will not work.
Generally, if you have more than one View.Update, you're using it wrong. (This includes if you have it inside a for loop somewhere)

An explanation:
View.Set('offscreeonly') will initiate double buffering. This means Turing will draw everything to a "back buffer", which is invisible, elsewhere. Its an 'imaginary' piece of space somewhere in memory. You will never see what is being drawn there until you 'flip' it onto the screen, using View.Update. "View.Update" copies the entire back buffer to the front buffer, where it becomes visible in the Turing run window. This is why, when you use offscreenonly, you cannot see what you are writing when you use the command "get".

To remedy the "I can't see what I'm inputting" problem, simply reset offscreenonly by using
code:

View.Set('nooffscreeonly')


Q: I'm getting an error when loading and drawing pictures. What does it mean?
Ans: Make sure you can answer 'yes' to the following questions:

  1. Is the picture in the same folder as the Turing program? If it's not, are you referencing it properly? The path to the picture can start with a "C:" (or another drive) to make the path absolute. If the drive is not included, the path is relative to the current directory, which is the directory that contains the Turing program.
    For example, if the folder that contains your Turing program also contains another folder called "images" that contains the picture you want to load, load it like this:
    code:

    Pic.FileNew ("images/my_picture.bmp") % where "my_picture.bmp" is the name of the picture in the "images" folder

  2. Is the format of the picture supported? Turing only supports .bmp, .jpg, and, if you have Turing v4.1, .gif. Are you sure that the file is actually the file type you think it is? Simply renaming the file in Windows Explorer does not change the file encoding. You need a program like MSPaint to convert between image types.
  3. Are you absolutely sure you got the name of the file right? Windows has a 'feature' to hide extensions of known file types. This can lead to files named "my_picture.jpg.jpg". Turn off that feature (Windows Explorer -> Tools -> Options -> Views) and check the filename again.
  4. Is the picture still there? That is, make sure you didn't Pic.Free it before drawing it.


Q: How do I move an object?
Ans:With variables! Check the Turing Walkthrough for details on how to use variables, and make sure you understand the draw command you are using thoroughly before using variables with it.

Q: How do I write a card game?
Ans: Unless the game is blackjack (or a version of it), you should probably try an easier program first, for the simple reason that you asked this question.

Alright, first of all, know arrays, the mod, and the div operators. Only one-dimensional arrays are needed. Now, on to the math part. Have all of your cards represented by a number between 0 and 51. Since there are 52 cards in the deck. 0 to 12 will be one suit (2 to A) 13 to 25 will be the next, etc.
For this FAQ, I will be using 0 = '2', 1 = '3', ... , 11 = 'K', 12 = 'A'.
In order to determine the value of the card, you simply use the mod operator.
cardNum mod 13 = cardValue. To determine the suit of the card, use the div operator.
cardNum div 13 = cardSuit.
0 = 'Spades'
1 = 'Hearts' etc...
Now, I'll explain why.
If you test it out, any number between 0 and 12 dived by 13 will result in an answer of 0. Is it coincidence that between 0 and 12, there are 13 numbers, and that is exactly how many cards there are per suit? No. Its math! And you told your grade 8 teacher you wouldn't be using math after the third year in high school Razz
Additionally, if you test it out, any number between 0 and 12 moded by 13 will result in its respective number. Any number between 13 and 25 will result in that number - 13.
That probably wasn't the best explanation, but if you understand exactly what div and mod do, then you should be able to grasp it. If you don't, then read up on what div and mod do.
And, for efficient output, read this.

Q: Where do I download Turing?
Ans: compsci.ca has set up a page for that here.

Q: Why can't I compile / save .exe of my program?
Ans: This is a known bug in Turing 4.1.1; use Turing 4.1 instead, available from the same place linked above.

If anyone has anything to add, feel free to, I may post up more later on if I think of anything else.

Note: I use the term 'we' to represent the compsci community interested in replying to help posted in the Turing Help section. If you disagree with anything i've said in this post, feel free to express your disgruntlement. (I think I just made up a word. Whee!)
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Sun Jun 04, 2006 9:59 am   Post subject: (No subject)

This could be a useful little post - which could in time be expanded on, having for faq's added. One thing you may want to fix is the . . prettyness (I think I just made up a word. Whee!) of the topic. It's kind of all mushed in together, and I think it would be more effective if it was less an eye sore - something that catches the eye a lot more.

But good work on it - maybe look up Cervantes tutorial on writing tutorials Smile.
Cervantes




PostPosted: Sun Jun 04, 2006 10:29 am   Post subject: (No subject)

jamonathin wrote:
One thing you may want to fix is the . . prettyness (I think I just made up a word. Whee!)

No, you just spelled "prettiness" wrong. Wink

Good job TheOneTrueGod! I hope to see this added to. One thing that definately needs to be added is "Why does my animation flicker?"

Too bad this is in a help forum where you can't edit it. Argh. Well, if you want to add anything, just PM me and I'll add it. Don't be alarmed if I or other mods add things ourselves. Wink I think I'll add some colour to this soon.

I'll be stickifying this now.
+50 bits for the work and the idea.
Delos




PostPosted: Sun Jun 04, 2006 6:22 pm   Post subject: (No subject)

Great effort TOTG. A few minor edits and prettiness added. Perhaps I should ask Tony to have this auto linked to [Turing FAQ].
To encourage use of this thread, I suggest that if a thread is found in which a question is posted whose answer is already documented herein, that that thread be referred to this thread, and the offending thread locked. How many clauses did I just use? Laughing
TheOneTrueGod




PostPosted: Sun Jun 04, 2006 8:15 pm   Post subject: (No subject)

Shocked gasp Shocked Its sexy now Very Happy Thanks for the praise guys. I gave Cervantes some more things to add, and if you have any other questions that you believe should be added, just post em here or PM me (Or if you're a mod, and you feel like it, add em yourself Razz) and i'll write up something for em.
Clayton




PostPosted: Tue Jun 06, 2006 11:30 am   Post subject: (No subject)

also about the flickering part.. theres a whole section about how to fix it here
[url]
http://www.compsci.ca/v2/viewtopic.php?t=12533
[/url]
it is my tutorial on View.Set and View.Update (dont know why its not in the Turing Walkthrough but whatever) Very Happy good stuff TheOneTrueGod
NikG




PostPosted: Wed Jun 07, 2006 10:51 pm   Post subject: (No subject)

Another common question is:
where can I download Turing/can you send me Turing?

I know it's not directly programming related but I believe it should still be in this faq somewhere near the top.
[Gandalf]




PostPosted: Thu Jun 08, 2006 11:48 pm   Post subject: (No subject)

The answer would then be found in one of the stickies in this forum:
No. We can't tell you where to download Turing.
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Fri Jun 16, 2006 3:58 pm   Post subject: (No subject)

how about one of the mods add something to the effect of "How do i change my mouse cursor to something cooler?" ive noticed a few people have been asking this question around here lately....
TheOneTrueGod




PostPosted: Fri Jun 16, 2006 4:27 pm   Post subject: (No subject)

I think that question will dissapear in about a week until next years final project season...
Clayton




PostPosted: Fri Jun 16, 2006 7:06 pm   Post subject: (No subject)

still itll be handy to have around so that more topics will be created to ask that question Smile
TheOneTrueGod




PostPosted: Wed Jun 21, 2006 7:58 pm   Post subject: (No subject)

Some more questions:

Q: How do I change the mouse cursor to something other than its default?
Ans: You cannot using Turings default commands. What you can do is search [url="www.google.com"]here[/url] for a program that will auto change the mouse cursor, and then run it using Sys.exec. I do however, ask that you please post notifying that your program will do this if you post it on this site.

Q: Where can I get a program like that?
Ans:Search google for it. Its not my job to do your research for you.

Q:How do I convert this string to an integer (Or real)?
Ans: Search through the Turing Help (F10) Menu for the following commands:
strintok, strint, strrealok, and strreal
Then, just use clever loops / procedures in order to check that their input was in fact convertable, then convert it.


Thats all for now, maybe more to come later.
Srlancelot39




PostPosted: Tue Sep 21, 2010 2:36 pm   Post subject: RE:Frequently Asked Questions (And Answers!)

I have a question to add...
I know it can be done but I forget how: How do you detect the prescence of a file before using it? Why would you want to do this? I want to do this because if a file cannot be found when it needs to be read, the program will crash...hence why I want it to look for the file first and return a value indicating whether it found it or not. If any one knows I'd love to hear it!
TheGuardian001




PostPosted: Tue Sep 21, 2010 2:59 pm   Post subject: Re: Frequently Asked Questions (And Answers!)

File.Exists

The turing help file is your friend.
Srlancelot39




PostPosted: Tue Sep 21, 2010 10:30 pm   Post subject: Re: Frequently Asked Questions (And Answers!)

TheGuardian001 @ Tue Sep 21, 2010 2:59 pm wrote:
File.Exists

The turing help file is your friend.

its ok i found out how! thx anyway!
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 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: