Serge D. Mechveliani wrote:
>
> People,
> consider the two simple programs for 1.input and 2.input respectively:
>
> -- 1 ------------------------------------------------------
> iReadinessFile: File String := open("readinessForAxiom.txt", "input")
> read!(iReadinessFile)
> if % = "1" then "done" else "not done"
> close! iReadinessFile
> -----------------------------------------------------------
>
> -- 2 ------------------------------------------------------
> iReadinessFile: File String := open("readinessForAxiom.txt", "input")
> repeat
> read!(iReadinessFile)
> if % = "1" then break else iterate
> close! iReadinessFile
> "done"
> -----------------------------------------------------------
>
> The aimed meaining is to wait till "1" appears in the file and then
> to do a certain thing.
> Is this an appropriate program?
>
> Now, put "1" to readinessForAxiom.txt and run the programs.
>
> -> )read 1 works correct.
>
> -> )read 2
> reports
> Cannot find a definition or applicable library operation named =
> with argument type(s)
> File(String)
> String
>
> Perhaps you should use "@" to indicate the required return type,
> or "$" to specify which version of the function you need.
> FriCAS will attempt to step through and interpret the code.
> There are 2 exposed and 8 unexposed library operations named =
> having 2 argument(s) but none was determined to be applicable.
> ...
>
> Can you explain, please?
> Thank you in advance for help,
Well, do _not_ use % when programming. % is value of previous
_toplevel_ expression. In first case % has intended value,
but is the second case current expression is then whole
'repeat' construct, and previous expression is assignmet
to iReadinessFile...
Some notes:
1) FriCAS file operations just read what is in the
file, with no provision to wait for new data, so to do
what you want you need freshly open the file and
read again from the beginning.
2) FriCAS file operations assume that data in the file
is of apropriate form. In particular, File(String)
expects that file contains sequence of strings
printed by Lisp.
3) To check if there is data you should use 'readIfCan!'.
'read!' gives error at end of file.
4) The 'else iterate' part is useless, and apparenty works
wrong. When I omit it loop is repeated, when it is
present then there is only one iteration.
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.