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

Username:   Password: 
 RegisterRegister   
 Need help with error messages
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Intet22




PostPosted: Mon Oct 31, 2011 9:54 am   Post subject: Need help with error messages

What is it you are trying to achieve?
I am trying to make it so I have a procedure that will check every text that is entered to make sure the program does not crash.


What is the problem you are having?
I can get the error messages to work for searching for files but not for get strings. They still crash the program if I input an incorrect input.


Describe what you have tried to solve this problem
As of yet not to much. I just tried to make it so all of the text went through the error check but it had an error so I took it out


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Here is the error code I had before that worked but I was wondering if I could adapt it.

Turing:


        %If there is an error this will display what error it is
        if Error.Last = eNoError then
            put "File Found"
        else
            put "Error: ", Error.LastMsg
        end if



Please specify what version of Turing you are using
Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Oct 31, 2011 12:37 pm   Post subject: RE:Need help with error messages

I think Error.Last only checks for error flags. If you actually try to use incorrect input, it will throw an exception that will terminate your program.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Intet22




PostPosted: Tue Nov 01, 2011 8:29 am   Post subject: Re: Need help with error messages

So is there anyway to check the exception so the program does not crash if the user inputs an incorrect input.
Tony




PostPosted: Tue Nov 01, 2011 10:28 am   Post subject: RE:Need help with error messages

Normally yes, but I'm not sure if Turing provides any mechanisms for catching exceptions before they run to the end of the program. You might have to just check the input for validity before it's used.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
tg851




PostPosted: Wed Nov 02, 2011 10:07 am   Post subject: Re: Need help with error messages

i find an
Turing:
if not (valid input)
then Error.Halt(error message here)

works quite well for if its only about up to 30 commands,past that it get tedious
matthewrohaly




PostPosted: Wed Nov 02, 2011 10:16 am   Post subject: Re: Need help with error messages

tg851 @ Wed Nov 02, 2011 10:07 am wrote:
i find an
Turing:
if not (valid input)
then Error.Halt(error message here)

works quite well for if its only about up to 30 commands,past that it get tedious


Although useful, would you mind posting more complete code? I think it would help OP a bit more.
tg851




PostPosted: Wed Nov 02, 2011 10:28 am   Post subject: Re: Need help with error messages

good point mat,forgot to say everything has to pretty strictly defined to do that,but posting code predone code for them is frowned upon you dunce,and considering were sitting across from eachother im going to punch you if you tell me to do that again
matthewrohaly




PostPosted: Wed Nov 02, 2011 10:37 am   Post subject: Re: Need help with error messages

tg851 @ Wed Nov 02, 2011 10:28 am wrote:
good point mat,forgot to say everything has to pretty strictly defined to do that,but posting code predone code for them is frowned upon you dunce,and considering were sitting across from eachother im going to punch you if you tell me to do that again


Sorry, but OP seems like he needed help and I was just hoping you would be able to provide him a bit more to help him. Plus your code you posted had no explanation, and I think OP could have used one. And please, tg851, threats are also frowned upon.

Sorry OP, I have failed you. Good Luck!

*leaves thread*
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Wed Nov 02, 2011 11:54 pm   Post subject: RE:Need help with error messages

@Tony, yes the mechanism exists, it's called handler. You use it at the beginning of a proc to describe what happens if an error is thrown within it. Then the handler can restart the proc, or clean something up and exit out.
Tony




PostPosted: Thu Nov 03, 2011 12:08 am   Post subject: RE:Need help with error messages

oh nice, this is kind of exciting Very Happy
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
mirhagk




PostPosted: Thu Nov 03, 2011 12:11 am   Post subject: RE:Need help with error messages

It's like an odd version of recursion when you use the handler to restart the procedure. Could def be useful though for certain things.
Tony




PostPosted: Thu Nov 03, 2011 12:18 am   Post subject: RE:Need help with error messages

well the exciting thing is that you can throw (and catch!) your own exceptions. I'd need to write something up about this when I get a chance.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
mirhagk




PostPosted: Thu Nov 03, 2011 1:18 am   Post subject: RE:Need help with error messages

I could work on something if you wanted? I can explain things decently, but I'm no good with formatting and making things look nice lol.

If you ever want a fun read, just read through random parts of the Turing docs. Ever heard of cheat? Did you know turing lets you set thread priorities? How about deferring procedure definitions (forward declaration)? Did you know turing actually has mechanisms to make threads wait for each other?

Pause and simutime are of particular interest. Essentially they work the same as Time.Delay and Time.Elapsed except every operation is counted as infinitely fast. The register command will place your variables in registers (well sometimes).

But the scariest of all is the indirection operator @. This little guy lets you read and write from ACTUAL MEMORY ADDRESSES!


My theory is that every feature that is missing from Turing is actually implemented somewhere but has gone unnoticed or is not documented (quite a few functions that aren't as we have come across)
tg851




PostPosted: Fri Nov 04, 2011 9:59 am   Post subject: Re: RE:Need help with error messages

mirhagk @ Thu Nov 03, 2011 1:18 am wrote:

My theory is that every feature that is missing from Turing is actually implemented somewhere but has gone unnoticed or is not documented (quite a few functions that aren't as we have come across)


so basically finding the needed functions in Turing basically ends up going through the code dictionary(or compiler)looking for the command while the Benny hill theme plays?reminds me of editing dwarf fortress raws...
Velocity




PostPosted: Wed Nov 09, 2011 3:44 pm   Post subject: RE:Need help with error messages

please post more complete code for full satisfaction.
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 1  [ 15 Posts ]
Jump to:   


Style:  
Search: