Re: Does 'seek' have to used with 'if'.....
John F Dutcher wrote:
>
> Here's a brief code sample that fails on the first occurence of the 'seek'
> attempt with this message:
>
> Syntax error:
> ... "expected possibly to see 'end', not a function"
> 'seek(fn, tobyte)'
Hi John,
yes, you fell for the old 'using-a-function-as-a-procedure' trick. I fall
the same thing at least half a dozen times a day too!
The rule in Euphoria is that a program *must* always do something with
the returned value from a function call. And 'seek' is a function. It
always returns a value. Its your choice how you use it, but you must
use it.
The value that 'seek' returns can be useful at times, but one easy way
to ignore it is to do this sort of thing ...
First, create a new *procedure*. Something like this will do ...
procedure set_file_position(integer fn, atom where)
fn = seek(fn,where)
end procedure
Then instead of using 'seek', use 'set_file_position'!
Such as ...
tobyte = 0
set_file_position(fn, tobyte)
Hope this helps.
--
Derek Parnell
Melbourne, Australia
|
Not Categorized, Please Help
|
|