Why Error?
05-19-2021, 02:38 AM (This post was last modified: 05-19-2021 02:43 AM by toml_12953.)
Post: #1
 toml_12953 Senior Member Posts: 1,949 Joined: Dec 2013
Why Error?
I'm using the 5/05 Beta and the latest beta of the virtual calculator.
When running the following program on the emulator (it works on the physical G2) I get an error between the semi-colon and the Xmax. Why?

Code:
EXPORT ErrPgm() BEGIN Xmin:=-15;Xmax:=370; END;

Tom L
Cui bono?
05-19-2021, 03:24 AM (This post was last modified: 05-19-2021 03:25 AM by Dougggg.)
Post: #2
 Dougggg Member Posts: 109 Joined: Dec 2013
RE: Why Error?
Not sure why there is an error, maybe builtin vairiables, but if I add

LOCAL Xmin, Xmax;

no error

EXPORT ErrPgm()
BEGIN
LOCAL Xmin, Xmax;
Xmin:=-15;Xmax:=370;
END;

works
05-19-2021, 03:29 AM (This post was last modified: 05-19-2021 03:30 AM by Tim Wessman.)
Post: #3
 Tim Wessman Senior Member Posts: 2,284 Joined: Dec 2013
RE: Why Error?
You are using an app variable. (specifically a graphing one)

Since you are not in a graphing application it cannot find it.

In the varible menu, click CTLG and see how many apps have Xmin as a varialbe. I assume you aree not trying to overite whatver user app is open?

TW

Although I work for HP, the views and opinions I post here are my own.
05-19-2021, 08:12 AM
Post: #4
 toml_12953 Senior Member Posts: 1,949 Joined: Dec 2013
RE: Why Error?
(05-19-2021 03:29 AM)Tim Wessman Wrote:  You are using an app variable. (specifically a graphing one)

Since you are not in a graphing application it cannot find it.

In the varible menu, click CTLG and see how many apps have Xmin as a varialbe. I assume you aree not trying to overite whatver user app is open?

I thought Xmin, Xmax, Ymin and Ymax were built-in variables that let me define my own screen coordinates.
Since they're not, how would I set the screen limits to plot points in a regular HPPL program? and why does the same program work on the physical calculator when both the virtual and physical calculators have no other user-defined programs or functions?

Tom L
Cui bono?
05-19-2021, 12:23 PM (This post was last modified: 05-19-2021 12:33 PM by C.Ret.)
Post: #5
 C.Ret Member Posts: 218 Joined: Dec 2013
RE: Why Error?
(05-19-2021 02:38 AM)toml_12953 Wrote:
Code:
EXPORT ErrPgm() BEGIN Xmin:=-15;Xmax:=370; END;

Since in this code Xmin and Xmax are not define as local variables, this code assume they exist in the global environment.

If the currently selected application have these Application Variables; no problem, your code will modify their value.

Please check if the emulator and the physical HP prime have the same application selected. this may explain the different behaviour.

Quote:
Code:
EXPORT ErrPgm() BEGIN LOCAL Xmin, Xmax; Xmin:=-15;Xmax:=370; END;

Here the two variables are local and the code runs without issue whenever the selected application have Xmin and Ymax global variables or not .
But, if your goal was to set any graphical coordinate for a future plot view, you fall ! Local variable have nothing to do with Graphic Plots ! So, you have to be sure a graphical application is selected before using Xmin Xmax Ymin Ymax etc plot window's varaibles.

To select an application in a program use the STARTAPP command:
Code:
EXPORT ErrPgm() BEGIN STARTAPP("Function"); Xmin:=-15;Xmax:=370; END;
This will start the Function application which use Xmin ... Ymax Application Variables .

Alternatively, you can qualify you global variable, just add the name of the Application in reference. This is the way to design an Application Variable independently of the current Application being selected:
Code:
EXPORT ErrPgm() BEGIN Function.Xmin:=-15; Function.Xmax:=370; END;
So you can qualify varaible of the Function Application when using another Application environnement.
05-19-2021, 06:55 PM
Post: #6
 Bram Junior Member Posts: 3 Joined: Mar 2021
RE: Why Error?
(05-19-2021 08:12 AM)toml_12953 Wrote:  ... and why does the same program work on the physical calculator when both the virtual and physical calculators have no other user-defined programs or functions?

Slightly, but not entirely OT:
I once encountered a similar situation when a program that ran smoothly on a real calculator (HP 29C) didn’t do on an emulated one. The program with a separation into individual digits from a fractional number worked fine thanks to the bcd construct of the (earlier) HP machines, but the emulator (on a pc in this case) uses binary, so that f x=y? may not correctly compare f.e. 0.1 from a calculation with 0.1 as a constant value anymore. The program filled the programming space entirely; there was no room for extra steps for a ‘better/safer’ comparison in the emulator.

It took a long time to figure this out, I remember. Learnt to be careful with emulators.
 « Next Oldest | Next Newest »