Computer Science Canada not sure how to get Turing to write at the end of a file ie. adding a new entry to a list |
Author: | dog44 [ Tue Jan 08, 2013 8:40 pm ] | ||
Post subject: | not sure how to get Turing to write at the end of a file ie. adding a new entry to a list | ||
What is it you are trying to achieve? i am trying to get Turing to write a new student entry at the end of a file What is the problem you are having? i don't know how to get Turing to only write the new information at the very end or anywhere in between for that matter Describe what you have tried to solve this problem i have a loop system that counts the number of lines and my place markers that show when a student entree is finished but i don't know how to get it to write to that particular line (the last line basically) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) Turing:
i am using Turing 4.1 |
Author: | jr5000pwp [ Tue Jan 08, 2013 9:21 pm ] | ||
Post subject: | Re: not sure how to get Turing to write at the end of a file ie. adding a new entry to a list | ||
If you are attempting to write to the end of a file, all the info you will need is on this page: http://compsci.ca/holtsoft/doc/open.html There is an example near the bottom of the page that will help with that. As for writing to the middle, you will probably want to read the file into your custom structure (It appears you have one called stumarks), modify it how you want, then write the structure again. For example if you have a structure of name and age and you wanted to add a structure into the file in alphabetical order you could do something like this (pseudocode/turing mixture so don't just copy and paste)
|
Author: | dog44 [ Tue Jan 08, 2013 10:27 pm ] | ||
Post subject: | Re: not sure how to get Turing to write at the end of a file ie. adding a new entry to a list | ||
thx for the advice i haven't tried the second half of your suggestion yet but i did try to use the first half (the link you gave me about using mod and seek) it looks like the example they gave me is either incorrect or im not doing something right cause every time i try to use it just overwrites the entire file with what i want to put in it
is there something im missing here ? do i have to do like put, mod in that put statement or just mod with a colon |
Author: | jr5000pwp [ Tue Jan 08, 2013 11:35 pm ] |
Post subject: | RE:not sure how to get Turing to write at the end of a file ie. adding a new entry to a list |
http://compsci.ca/holtsoft/doc/seek.html has another example, however, what you put seems valid. There might be a problem somewhere else in your code, or it might be a broken feature. Another option is to read the data in and then write it back to the file, and there are some optimizations so you don't have to use an array, but you should be able to put to the end of the file. I do not see anything wrong with the snippet you provided, however, if you post the code (probably as a file), I can see if there's something else wrong. |