Post Reply 
Firmware 2021 - Test PRINT and PRINT2D cmds
04-16-2021, 11:17 PM (This post was last modified: 04-28-2021 06:52 PM by compsystems.)
Post: #1
Firmware 2021 - Test PRINT and PRINT2D cmds
Hello hp¹s

In firmware 2021, we have a new PRINT2D command in math book print format. =]

A: PRINT2D does not work in CAS mode =(

Quote:PRINT2D Syntax:
PRINT2D(obj, [font], [color], flags)
PRINTED )
Prints either the result of expr or string to the terminal. The display will be done using textbook display

B: The tab symbol must be invisible in terminal view and visible in edit as ⇥

PHP Code:
    PRINT( "Hello\n\tworld \\ \" " ); //   Hello world \ "
    
PRINT2D"Hello\n\tworld \\ \" " );
    print( 
"Hello\n\tworld \\ \" " ); 

Basic escape characters work great in the code editor, but not yet in the history view =(

Test PRINT & PRINT2D cmds
HOME MODE:

PHP Code:
EXPORT print_cmds_home()
BEGIN
    
PRINT(); // Clear terminal output
    
PRINT( (50 5*6) / ); // 5, evaluates, ok
    
PRINT2D( (50 5*6) / ); // 5, evaluates, ok
    
PRINT( "\n" ); // new line, ok
    
    
PRINT( quote(2) ); // 5^2, 1D without evaluating, ok
    
PRINT( '5 ^ 2' ); // 5^2, 1D without evaluating, ok
    
PRINT2Dquote(2) ); // 5² , 2D without evaluating, ok
    
PRINT2D'5 ^ 2' ); // 5² , 2D without evaluating, ok
    
PRINT( ); // 25, ok
    
PRINT2D); // 25, ok
    
PRINT( "\n" );

    PRINT( 
'(50 - (5*6)) / 4' ); //     1D without evaluating, ok
    
PRINT2D'(50 - (5*6)) / 4' ); // 2D without evaluating, ok
    
PRINT( "\n" );
    
    PRINT( 
"Hello\n\tworld \\ \" " );  //   Hello world \ "
    
PRINT2D"Hello\nworld" );
    PRINT( 
"\n" );

    
PRINT2D'17 / 3' ); // 17/3, rational division without evaluating, ok
    
PRINT2D17 ); // 5.6666... , approximate value calculation, ok
    
PRINT( "\n" );
    
    
PRINT2D'floor(17 / 3)' ); // print as function floor(17 / 3), but ⌊ 17/3 ⌋ is real 2D mathbook print, 8970 (⌊) & 8971(⌋)    unicode char
    
PRINT2Dfloor(17 3) ); // 5, ok, floor division discards the fractional part
    
PRINT( "\n" );
    
    
PRINT2D'ceiling(17 / 3)' ); // print as ceiling(17 / 3), but ⌈ 17/3 ⌉ is real 2D mathbook print, 8968(⌈)/8969(⌉) unicode char
    
PRINT2Dceiling(17 3) ); // 6
    
PRINT( "\n" );
    
    
PRINT2D'17 MOD 3' ); // 17 MOD 3
    
PRINT2D17 MOD 3 ); // 2, ok, the MOD operator returns the remainder of the division
    
PRINT( "\n" );
    
    
PRINT2D'abs(3+4*i)' ); // | 3 + 4i |, ok
    
PRINT2Dabs(3+4*i) ); // 5, ok
    
PRINT( "\n" );

    RETURN( 
"Done" );
END

Test print (lowercase) cmd
CAS MODE:
PHP Code:
#cas
print_cmds_cas():=
BEGIN
    
print(); // Clear terminal output
    
print( (50 5*6) / ); // 5, evaluates, ok
    
print( (50 5*6) / ); // 5, evaluates, ok
    
print( "\n" ); // still not print new line =(
    
    
print( string(quote(2) )); // "5^2", 1D without evaluating
    
print( string('5 ^ 2') ); // "5^2", 1D without evaluating
    
print( quote(2) ); // 5² , 2D without evaluating, ok
    
print( '5 ^ 2' ); // 5² , 2D without evaluating, ok
    
print( ); // 25, ok
    
print( ); // 25, ok
    
print( "\n" );

    print( 
string('(50 - (5*6)) / 4' )); //  1D without evaluating
    
print( '(50 - (5*6)) / 4' ); // 2D without evaluating, ok
    
print( "\n" );
    
    print( 
"Hello\n\tworld \\ \" " );  //   Hello world \ "
    
print( "Hello\nworld" );
    print( 
"\n" );

    print( 
'17 / 3' ); // 17/3, rational division without evaluating, ok
    
print( 17 3. ); // 5.6666... , approximate value calculation, ok
    
print( "\n" );
    
    print( 
'floor(17 / 3)' ); // print as function floor(17 / 3), but ⌊ 17/3 ⌋ is real 2D mathbook print, 8970 (⌊) & 8971(⌋)  unicode char
    
print( floor(17 3) ); // 5, ok, floor division discards the fractional part
    
print( "\n" );
    
    print( 
'ceiling(17 / 3)' ); // print as ceiling(17 / 3), but ⌈ 17/3 ⌉ is real 2D mathbook print, 8968(⌈)/8969(⌉) unicode char
    
print( ceiling(17 3) ); // 6
    
print( "\n" );
    
    print( 
'17 MOD 3' ); // 17 MOD 3
    
print( 17 MOD 3 ); // 2, ok, the MOD operator returns the remainder of the division
    
print( "\n" );
    
    print( 
'abs(3+4*i)' ); // | 3 + 4i |, ok
    
print( abs(3+4*i) ); // 5, ok
    
print( "\n" );

    RETURN( 
"Done" );
END;
#end 

output comparison between HOME and CAS
[Image: print2d_hp_prime_2021_img00.png]
Find all posts by this user
Quote this message in a reply
04-19-2021, 01:35 PM
Post: #2
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Hello,

Unfortunately, I do not think that I will be able to do much about the print and CAS mode...
PPL/CAS integration can only go so far without doing a LOT of work...

As far as the "tab" goes, how many spaces would you like it to be? 2 or 4?

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
04-19-2021, 02:10 PM
Post: #3
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Hello,

Actually, I will just replace the tab with a single space...
Prime does not use a monospace font, so you should not be using tabs anyway :-)



_______ _ _ _ _
|__ __| | | | | | | | |
| | __ _| |__ ___ __| | ___ _ __ ___ | |_ __ _____ _ __| | __
| |/ _` | '_ \/ __| / _` |/ _ \ | '_ \ / _ \| __| \ \ /\ / / _ \| '__| |/ /
| | (_| | |_) \__ \ | (_| | (_) | | | | | (_) | |_ \ V V / (_) | | | <
|_|\__,_|_.__/|___/ \__,_|\___/ |_| |_|\___/ \__| \_/\_/ \___/|_| |_|\_\



Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
04-20-2021, 06:27 AM
Post: #4
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Hello,

I have fixed the improper escape decoding...

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
04-24-2021, 04:21 AM (This post was last modified: 04-24-2021 04:26 AM by compsystems.)
Post: #5
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
(04-20-2021 06:27 AM)cyrille de brébisson Wrote:  Hello,

I have fixed the improper escape decoding...

Cyrille

ok, now it prints fine only in Terminal View, but not in the History View display, and in the [Show] screen, because it prints a little box □.

Inside the code it is not convenient to show spaces, better a tab symbol and more when the code is python (tab character (#09h) as an arrow ↦ , ⇥ or this you can modify the text font by replacing the empty or box character □ with an arrow ⇥, because with white spaces it is difficult to determine the indentation

PHP Code:
EXPORT prg1()
BEGIN
    
return "hello\n\tworld";
    
END
prg1() [enter] "hello\n\tworld" [up] [show] hello world

[Image: print2d_hp_prime_2021_img02.png]
Find all posts by this user
Quote this message in a reply
04-24-2021, 09:13 AM
Post: #6
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
(04-19-2021 01:35 PM)cyrille de brébisson Wrote:  As far as the "tab" goes, how many spaces would you like it to be? 2 or 4?

Cyrille

Considering that a calculator has limited horizontal real-estate, I'd suggest that 'tab' spacing should be 2 characters.
Find all posts by this user
Quote this message in a reply
04-24-2021, 03:37 PM
Post: #7
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Yes, I'm using 2 spaces in KhiCAS.
Find all posts by this user
Quote this message in a reply
04-24-2021, 05:03 PM
Post: #8
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Hello
Mr parisse
Why in CAS mode QUOTE or '' it is not working?, that is, when printing it evaluates the expression

PHP Code:
PRINT2Dquote(2) ); // 5² , 2D without evaluating
    
PRINT2D'5 ^ 2' ); // 5² , 2D without evaluating 
Find all posts by this user
Quote this message in a reply
04-24-2021, 05:54 PM
Post: #9
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
PRINT2D is not a CAS command.
Find all posts by this user
Quote this message in a reply
04-24-2021, 06:58 PM
Post: #10
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
On the subject fonts in the Python text editor, I noticed that the Alpha status indicator in the top bar displays incorrect information. It shows the font as being capitalised when it's lower case and visa versa.
Find all posts by this user
Quote this message in a reply
04-28-2021, 05:54 PM (This post was last modified: 04-28-2021 06:08 PM by compsystems.)
Post: #11
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
eval is a supercommand, an example with to print cmd
frn info: http://www-fourier.ujf-grenoble.fr/~pari...tml#sec338

In the following code you can see that to clean the screen I use
PRINT(); & Print;

print cmd without parentheses in CAS mode clears the screen, while at HOME it requires (), for this reason an improvement is that print() in CAS is interpreted as a clear screen, because when a code is executed any mode (CAS or HOME) works the same

PHP Code:
#cas
eval_cmd_cas():=
BEGIN
    
PRINT(); print; // clear terminal view
    
purge(r); purge(p); purge(q); purge(t); // purge(r,p,q,t);
    
a:=1+i*r
    
r:=p+1;
    
p:=q;
    
q:=t;
    
t:=-4;
    print(
a); // 1-3*i > 1+i*r > 1+i*(p+1) > 1+i*(q+1) > 1+i*(t+1) > 1+i*(-4+1) > 1-3*i
    
print(eval(a,1)); // 1+i*r
    
print(eval(a,2)); // 1+i*(p+1) 
    
print(eval(a,3)); // 1+i*(q+1) 
    
print(eval(a,4)); // 1+i*(t+1)
    
print(eval(a,5)); // 1+i*(-4+1) > 1-3*i
     
print(eval(a,0));        
    return 
"Done";
end;    
#end 

Another very useful improvement is that when placing a variable of the name of a CAS type function from the [var] menu, it automatically places an empty parenthesis as a suffix after the name of the program.
eval_cmd_cas> eval_cmd_cas()
The reason is that without parentheses it is considered as RCL or call of the content of the function and not as its execution.
Find all posts by this user
Quote this message in a reply
04-28-2021, 10:51 PM (This post was last modified: 04-28-2021 11:04 PM by compsystems.)
Post: #12
RE: Firmware 2021 - Test PRINT and PRINT2D cmds
Hi, the following code works fine from HOME mode, but not from CAS mode.

Note that it uses WAIT cmd, to stop printing, in the hp48 and 50 series it showed HALT at the top, this is important to know that the printing is paused, I think it is also important to place this message, it may be above the la current time
Thanks


PHP Code:
#cas
test_expr2Dprint_CAS():=
BEGIN
    local x
,y;
    
purgef);
    PRINT(); print; 
// clear terminal view
    
print( "2D printing, Press any key to continue" ); wait;
    print( 
"\n" );
    print( 
"Expr1:" );
    print( 
'f(x) = x^3 - 2*x^2 + x -1' );
    
f(x) := x^2*x^-1wait;
    print( 
"\n\n" );

    print( 
"Expr2:" );
    print( 
'f(x) | (x=y)' ); wait;
    print( 
'x^3 - 2*x^2 + x -1 | (x=y)' ); wait;
    print( 
f(x) | (x=y) ); wait;
    print( 
"\n\n" );

    print( 
"Expr3:" );
    print( 
'g(x) = 1/(x+3)' );
    
g(x) := 1/(x+3); wait;
    print( 
"\n\n" );

    print( 
"Expr4:" );
    print( 
'f( g(x) )' ); wait;
    print( 
'x^3 - 2*x^2 + x -1 | ( x=g(x) )' ); wait;    
    print( 
'x^3 - 2*x^2 + x -1 | ( x = 1/(x+3) )' ); wait;    
    print( 
fg(x) ) ); wait;
    print( 
"\nsimplify:" );
    print( 
simplifyf(g(x)) ) ); wait;
    print( 
"\n\n" );

    print( 
"Expr5:" );
    print( 
'g( f(x) )' ); wait;
    print( 
'1/(x+3) | (x=f(x))' ); wait;
    print( 
gf(x) ) ); wait;
    print( 
"\nsimplify:" );
    print( 
simplifyg(f(x)) ) ); wait;

    print( 
"\nDone" );
    return 
"Done"

end

HOME mode
test_expr2Dprint_CAS() [enter] ok, but in the end it returns the source code, this is because the name of the program suppresses the parentheses
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)