Author |
Message |
qmanjr5
|
Posted: Fri Dec 11, 2009 9:26 pm Post subject: Marking a place in the code |
|
|
Okay, the best way I can explain this is in .bat file code (MS-DOS Command Prompt stuff, I can't remember the real name)
code: |
*code*
goto area1
:area1
*code*
goto area2
:area2
|
Now, I was just wondering if there was a way to do this in turing?
Like a bookmark of sorts. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
|
|
|
 |
qmanjr5
|
Posted: Fri Dec 11, 2009 9:33 pm Post subject: RE:Marking a place in the code |
|
|
well, I just learnt about the GUI buttons thing, and since i'm making a quiz, I was thinking about doing several difficulty levels, and when you click a button, i want it to go to the difficulty level.
I know I can make a process/procedure for each difficulty level, but I thought that since I don't know if it's possible, that I could ask to see if marking a place in the code is possible, to make it easier. |
|
|
|
|
 |
Tony

|
|
|
|
 |
qmanjr5
|
Posted: Fri Dec 11, 2009 9:48 pm Post subject: RE:Marking a place in the code |
|
|
Does that help me?
can't you just type it out :'( |
|
|
|
|
 |
Dan

|
Posted: Fri Dec 11, 2009 10:00 pm Post subject: Re: Marking a place in the code |
|
|
Edsger W. Dijkstra wrote:
For a number of years I have been familiar with the observation that the quality of programmers is a
decreasing function of the density of go to statements in the programs they produce.
What you are trying to do is a goto. It's largely conisdered to be a rather bad partice other then in a few very limited cases.
To my knowagle turing does not support goto or anything like it. However even if it did, it would not as the GUI button needs to take a procedure.
You did not post your code, so it's hard to say what you should do but creating a procedure that simply sets a varible repesenting the diffculity level seems like the easyest method. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
 |
Tony

|
Posted: Fri Dec 11, 2009 10:01 pm Post subject: RE:Marking a place in the code |
|
|
That is a horrible idea and it would not be easier.
You'd need to mark beginning and ending of the "levels", so you'd be doing as much work as marking beginning and ending of the "procedure" that wraps around the levels. So you are trying to do what procedures are meant to do, but in a way that will make it more difficult to understand. So no, you don't get to do that. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
qmanjr5
|
Posted: Fri Dec 11, 2009 10:03 pm Post subject: RE:Marking a place in the code |
|
|
It's not that I want to do this solely for the quiz, but just to know.
So, I'm going to have to do procedures for each level? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Dan

|
Posted: Fri Dec 11, 2009 10:19 pm Post subject: Re: RE:Marking a place in the code |
|
|
Idealy your quiz program would read a set of questions, possible awnsers and the correct awnser from a file and changing the diffuculity should simply mean chaning what file is used and not jumping around in code. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
 |
Insectoid

|
Posted: Fri Dec 11, 2009 11:48 pm Post subject: RE:Marking a place in the code |
|
|
You should have 1 procedure that takes an array of questions and an answer as a parameter, then call it as many times as there are questions (more than likely via a for loop) |
|
|
|
|
 |
qmanjr5
|
Posted: Sat Dec 12, 2009 2:45 am Post subject: RE:Marking a place in the code |
|
|
So, no "goto" type of command? :'( |
|
|
|
|
 |
Tony

|
|
|
|
 |
qmanjr5
|
Posted: Sat Dec 12, 2009 2:02 pm Post subject: RE:Marking a place in the code |
|
|
Alright, thanks anyway guys
I'll guess I'll just make procedures for the levels.
I appreciate it  |
|
|
|
|
 |
mirhagk
|
Posted: Sat Dec 12, 2009 3:22 pm Post subject: RE:Marking a place in the code |
|
|
just out of curiousity why is a goto command a bad thing?? and is it still considered bad coding practice in assembly (using the JMP command??) |
|
|
|
|
 |
DemonWasp
|
Posted: Sat Dec 12, 2009 4:33 pm Post subject: RE:Marking a place in the code |
|
|
GOTO is considered bad because it results in a much more complicated flow of control than using proper IF, LOOP, FOR and procedure/function constructs would. With proper structures, it's much easier to analyse the flow of control and correct errors in the program. In many assembly languages, there are actually go-subroutine and return-from-subroutine instructions, though if statements and for/loop still compile to JMP and conditional-jump instructions. |
|
|
|
|
 |
|