previous next top contents index framed top this page unframed
getPos returns the current position of f, in character units.
Example 36–12. Use of getPos
| INTEGER c,j,k; LONG INTEGER pos,savePos; POINTER(textFile) f; open(f,"results",create!random); # Suppose you are writing characters to f and you come to # a point where you know another character is needed, # but you don't yet know its value and you need to # write out other characters before you will know its # value. You can save the position at which this # character belongs, savePos := getPos(f); # temporarily write out an "x", say, as a place holder, cWrite(f,'x'); # and then continue writing out other characters, e.g., write(f,"abc"); . . . # until you know the value of the original character, # say c, so you can replace the "x" written in its place # with the proper value. Save the current position in f, # position back to the position for the character c, write # out the desired character, and position back to where # you were to continue writing more characters: pos := getPos(f); setPos(f,savePos); cWrite(f,c); setPos(f,pos); |
MAINSAIL Language Manual, Section 36.13