From: Josef 'Jupp' Schugt Date: 2003-09-14T06:13:06+09:00 Subject: Re: [ANN] rcalc 2.3 (Was: [ANN] rcalc 2.2) Saluton! * Josef 'Jupp' Schugt; 2003-09-11, 19:24 UTC: > As far as the use of semicolon is concerned: I want to use it as a > comment character (as it is in LISP). This has been implemented in 2.3 now. Follows an example rcalc script that illustrates usage of comments. Note that the handling of strings has been enhanced. They are left intact and you can use escape sequences. Supported sequences are \", \', \\, \a, \b, \e, \f, \n, \r, \t, \v, \o, \oo, \ooo, \xh, and \xhh where 'o' is an octal digit and 'h' an hexadecimal one. I did notice that there is a need for some command to flush the whole stack. That command now exists and is called 'clear'. You are irrited by the name of this function? Ask Matz why he did choose it. 'clear' does nothing but call arr.clear - the Engine class that is responsible for computations is a superclass of the Array class. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Compute kinetic energy from mass and speed ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 'mass [kg]?' in ; input mass in kg (we call it m) 0.5 x ; TOS now is 0.5 * m 'speed [m/s]?' in ; input speed in m/s (we call it v) sqr x ; TOS now is 0.5*m*v**2 '\nkinetic energy [J]' ; explanatory string is pushed p ; stack is printed ; Let us suppose you enter 3 for m and 5 for v. ; After running the script you see this on your screen ; (Without the '; ' at the beginning of each line of course): ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 'mass [kg]?' ; 3 ; 'speed [m/s]?' ; 5 ; ; kinetic energy [J] ; 37.5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; You notice that you can use escape sequences, don't you? > BTW: I found a bug in interactive and script mode that is related > to splitting lines - strings in quotation signs are split, too. I > will look into that. This bug now is fixed. Gis, Josef 'Jupp' Schugt -- Scientific RPN calculator (in Ruby) http://rcalc.rubyforge.org/