Question reguarding the "seek" command
Author |
Message |
Junkhead
|
Posted: Tue May 02, 2006 9:14 pm Post subject: Question reguarding the "seek" command |
|
|
As far as I know, the seek command works like this:
seek: filestream, position
How does that "position" variable work? Does it seek on the X axis or the Y axis? How does the seek command know when to go down a line in the file? It just isn't clear to me, can someone clarify this?
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue May 02, 2006 9:42 pm Post subject: (No subject) |
|
|
I'm quite interested in your theory about X and Y axis inside of a file
What is a line anyways? To me it is a \n character in a continues string of text
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Junkhead
|
Posted: Wed May 03, 2006 11:09 am Post subject: (No subject) |
|
|
Well, lets say that the file is arranged in a grid-like formation. See what I mean now?
Moving it X would move the cursor right and left, and moving it Y would move the cursor up and down.
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed May 03, 2006 11:22 am Post subject: (No subject) |
|
|
there's no such thing, file's content is a continues string. As I've said before, "new line" character is still a character. As such the position can only be moved left and right.
I suppose that if you were to read forward for as many characters as you consider a "line" to be long, you'd move to the "next one"
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Junkhead
|
Posted: Wed May 03, 2006 11:48 am Post subject: (No subject) |
|
|
How would I output the contents that this program outputs to the screen in a file then?
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
sine.t |
Filesize: |
730 Bytes |
Downloaded: |
63 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Wed May 03, 2006 12:01 pm Post subject: (No subject) |
|
|
Let's clear up a common confusion before we continue. There is a big different between text output and graphical output. As it stands, your programme right now deals with graphical output, despite the fact that the put statements deal with text input.
A heuristic to follow is if you've used commands like locate(), colour(), or anything Draw.(), then you're dealing with graphics. (You could also use setscreen("text") and try to run it from there, you'll get error messages all over the place).
Now that we've established that what you have in your output screen is a drawing and not a series of strings, we can move forward.
It is quite possible to write a file that emulates the drawing you have. You've got a formula going in there, all that remains is for you to figure out where characters will be placed line by line.
One possiblity that springs to mind (a long, inefficient one at that!) would be to create a 2-dim array spanning the screen, and whereever you have a locate(), assign those same coordinates in the array to the same character...
So if you had a "T" being placed at (4, 12) then in your array, element (4, 12) would be assigned a "T" as well.
You could then write the array to a file. Not the best way of doing this, I'd suspect, but it's quick and dirty, and works.
|
|
|
|
|
![](images/spacer.gif) |
Junkhead
|
Posted: Wed May 03, 2006 5:17 pm Post subject: (No subject) |
|
|
Thanks for the help, guys, I think I know where I'm going to take this from here
|
|
|
|
|
![](images/spacer.gif) |
|
|