Computer Science Canada "Illegal get item" error. |
Author: | skingston [ Mon Jun 03, 2013 3:55 pm ] | ||
Post subject: | "Illegal get item" error. | ||
What is it you are trying to achieve? I am trying to load a euchre deck of cards from a text file into an array of records - "cards" What is the problem you are having? When I compile and run the program, I get the error message "Illegal Get Item" Describe what you have tried to solve this problem I'm not sure where to start Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) Here is the code:
Please specify what version of Turing you are using 4.1.1 |
Author: | DemonWasp [ Mon Jun 03, 2013 4:05 pm ] |
Post subject: | RE:"Illegal get item" error. |
That error message is incredibly unhelpful (Turing's fault, not yours). The problem is that you have declared the cards argument without the var keyword. If you look at http://compsci.ca/holtsoft/doc/procedure.html , you can see that parameter declarations have a form described at http://compsci.ca/holtsoft/doc/paramdeclaration.html . The optional [ var ] has this documentation: Turing Help wrote: Parameters to a procedure may be declared using var, which means that the parameter can be changed inside the procedure.
Unfortunately Turing is pretty awful at error messages (compared to modern languages, anyway). It should tell you that you can't change a constant (not variable) object, but instead you get that unhelpful error message. |
Author: | evildaddy911 [ Mon Jun 03, 2013 4:09 pm ] | ||||
Post subject: | RE:"Illegal get item" error. | ||||
mostl likely you are attempting to read past the end of the file. you are trying to read 24x2 items. make sure that A) you have 48 items in the file and B) they all are separated by a single space or the next item is on a new line. for example (reading "_" as a space): ok file:
unreadable file:
things wrong with this file: 1) between the 9 and 1 there is a double space, causing the program to read the second item as " 1" 2) no space between J and 1. program will read "J1" as a single item 3) empty line: the second newline will be read as an item 4) [space][newline] will cause the program to think that the next item is "[newline]K" Also, if you are having I/O problems, then usually it would be a good idea to give us the file that you are having troubles with along with the code EDIT: sorry, I was busy posting and didn't see your post first. That is most likely the problem, although you should check and make sure your file will be read the way you intend it too |
Author: | skingston [ Mon Jun 03, 2013 4:36 pm ] |
Post subject: | Re: RE:"Illegal get item" error. |
DemonWasp @ Mon Jun 03, 2013 4:05 pm wrote: That error message is incredibly unhelpful (Turing's fault, not yours).
The problem is that you have declared the cards argument without the var keyword. If you look at http://compsci.ca/holtsoft/doc/procedure.html , you can see that parameter declarations have a form described at http://compsci.ca/holtsoft/doc/paramdeclaration.html . The optional [ var ] has this documentation: Turing Help wrote: Parameters to a procedure may be declared using var, which means that the parameter can be changed inside the procedure.
Unfortunately Turing is pretty awful at error messages (compared to modern languages, anyway). It should tell you that you can't change a constant (not variable) object, but instead you get that unhelpful error message. Thank you sooooo much! The 'var' keyword was all I needed. |