[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: yabasic problem


i still have a HP BASIC 2.0 Quick Reference somewhere ...

Richar Owlett wrote:
> fd_in=open("/home/richard/Documents/cherrytree/edit_bookmarks/expermental_copies/prettytest0txt","r")
> print peek$("error")

Although the open() call does not really look like BASIC, it is authorized
by http://www.yabasic.de/yabasic.htm#ref_open

But shouldn't you test fd_in for failure (i.e. whether it is 0 after the
call) ?

The description of peek$("error") indicates that your BASIC program
should not even reach the message print command if open() failed.
It does not promise that the error indicator is reset when a new open()
or seek() is performed.

> Suggestions?

#ref_peek suggests
  if you use open as a condition (e.g. if (open(#1,"foo")) …) the outcome
  (success or failure) of the open-operation will determine, if the
  condition evaluates to true or false. If now such an operation fails,
  your program will not be terminated and you might want to learn the
  reason for failure. This reason will be returned by peek("error")
 (as a number) or by peek$("error") (as a string)

Mandatory deviation from literally answering the original question:
Even considering all sweet nostalgy, i would still stay with C as language.

Have a nice day :)


Reply to: