Flag for prog-call from within plot app

136 views
Skip to first unread message

Blaubeer Marmelade

unread,
Mar 9, 2026, 3:28:45 PMMar 9
to Free42 & Plus42
Hello all,
As you know, the plot application in plus42 can iteratively call a prg to calculate the function values. If there is a varmenu in this prg however, it should be bypassed if called for plot.
Is it possible to recognize from within a prg, if it is called by plot app?
As an example: the prog call from solver app can be checked by ...SF? 45...
BR
Dominik

Thomas Okken

unread,
Mar 9, 2026, 6:50:49 PMMar 9
to Free42 & Plus42
The numbered flags are already all in use, but I could add a function PLOT? to allow checking whether PLOT is active.

I'm not sure I understand the use case, though. PLOT is more flexible than SOLVE and INTEG in how it handles parameters and return values, so the need for this PLOT? feature isn't clear to me. Could you give an example where this would be used?

Blaubeer Marmelade

unread,
Mar 10, 2026, 5:00:03 PMMar 10
to Free42 & Plus42
Hello Thomas,
thank you for your response. I think, PLOT? would do it. 
My usecase is a fit-program for expressions like  
c1 + c2 * sin( C*x) + c3 * x + c4 * x^2 + ...
C is a nonlinear parameter which needs a SOLVE to be fitted. The linear ci parameters can be determined by the program COEFFIT which is given below in full length - for community and for discussion of further aspects later on (no claim for beauty, but it works)
Before start, the following - or a similar - expression should be defined in EQN-list: 
MONOMS(X:C):[ 1 : SIN(C*X) : X : X*X :  X*X*X : COS(X)  ]
The NDATS x 2 matrix  XYDATS  should contain the data points to be fitted
NDEG = Number of summands to be used from MONOMS for the fit-expression
C = Value for the nonlin. parameter
As output, you will get the fit-error in X-reg. This error is a function of C.
SOLVE can be started for C to minimize the error resulting in a best fit.
To get an idea where to find the region for best fit (-> initial guess for C) a previous plot of error(C) is very useful. This is now, where PLOT? would give its value: To avoid, that VARMENU pops up.
BR
Dominik

LBL "COEFFIT"
MVAR "XYDATS"
MVAR "NDEG"
MVAR "C"
SKIP
"--SOLVERMODE?"
FS? 45
GTO A
-----
SKIP
"--PLOTMODE?"
PLOT?
GTO A
-----
VARMENU "COEFFIT"
STOP
EXITALL
FUNC 33
LBL A
SKIP
"--INIT NDATS"
RCL "XYDATS"
SKIP
"DIM? EATS X-RG"
DIM?
ROLL_DOWN
LSTO "NDATS"
SKIP
"--INIT MCOEFFS"
RCL "NDEG"
NEWMAT
LSTO "MCOEFFS"
SKIP
"--INIT YDATS"
RCL "NDATS"
1
NEWMAT
LSTO "XDATS"
LSTO "YDATS"
LSTO "INITVEC"
SKIP
"--START LOOP--"
SKIP
"--NDATS...3.2.1"
LBL 00
SKIP
XSTR "--GET DATS FROM XYDATS FRM BOTTOM UP"
SKIP
"GETMI KEEPS X;Y"
RCL "NDATS"
1
GETMI "XYDATS"
STO "X"
EVAL 'MONOMS(X:C)'
SKIP
"MONEVAL=Nx1"
LSTO "MONEVAL"
SKIP
"--MONVL->1xNDEG"
1
RCL "NDEG"
DIM "MONEVAL"
SKIP
"--INITVCxMONVL"
0
STO* "INITVEC"
RCL "NDATS"
1
1.0
PUTMI "INITVEC"
RCL "INITVEC"
RCL* "MONEVAL"
STO+ "MCOEFFS"
SKIP
"--GET Y-VAL"
RCL "NDATS"
2
GETMI "XYDATS"
RCL* "INITVEC"
STO+ "YDATS"
DSE "NDATS"
GTO 00
SKIP
"--LOOP END--"
SKIP
"--NDATS=0"
RCL "MCOEFFS"
LSTO "MTMCOEF"
TRANS
DUP
RCL* "MTMCOEF"
INVERT
X<>Y
RCL* "YDATS"
*
STO "FITCOFS"
SKIP
"...FOR Z-RG"
SKIP
"--PREDICT YDATS"
DUP
RCL "MCOEFFS"
X<>Y
*
RCL- "YDATS"
SKIP
"...FOR Y-RG"
SKIP
XSTR "--CALC RMS ERROR BY DOT NEEDS 1xNDATS"
DUP
TRANS
DUP
DOT
SQRT
SKIP
"...FOR X-RG"
END


Blaubeer Marmelade

unread,
Mar 12, 2026, 3:44:49 PMMar 12
to Free42 & Plus42
Two further questions in connection to the "COEFFIT" program given above:
1) What is currently the shortest way in PLUS42 to plot the resulting fit-function together with the data points "xydats" into same plot?
2) I find these "small comments" very useful, using SKIP to mask them, ugly however for 2 or more line comments. If you do not see a more elegant way, what about the extension SKIP 2 , SKIP 3, SKIP n to skip the next 2 or 3 or n lines?
Of course, a special char to mark a comment line of arbitrary length would not be bad either...


Blaubeer Marmelade

unread,
Mar 31, 2026, 3:40:00 PM (3 days ago) Mar 31
to Free42 & Plus42
More observations which may improve the user experience in PLUS42:

3. Shift function on virtual keyboard
In EQN mode, an equation can be written or edited by pressing NEW or EDIT. I like the option to use a virtual keyboard during editing (turn on/off by tap on right screen boundary). Is it possible to couple the SHIFT key on virtual keyboard with the yellow key activation on the calculator keyboard? This means, pressing Shift will not only switch capital to lowercase letters, but will activate/deactivate yellow key at the same time. Would enable to use, e.g., the second functions of arrow softkeys (fast forward etc.) without need to switch between keyboards. Of course, just as yellow key, shift mode should disappear after pressing arrow softkey.

4. Inline editor in program mode
It would be wonderful to have the same editor as in EQN mode to edit single lines in program mode. A smooth way to call the editor for a current program line could be, e.g., to press or long-press SHOW (yellow key + .)

4.5
...And yes, I sometimes try to reposition the cursor intuitively with a finger tap on the screen... how I only could...

5. Fast way to a specific catalog entry by pressing first letter on virtual keyboard
I do not enjoy scrolling through the FCN menu. Nevertheless, it's in alphabetic order. So, why not using the first letter of a command for fast navigation to it? 
For "professionals", it could be allowed to press a number N followed by a letter to reach the Nth appearence of a menu entry starting with given letter. Or 17* to reach the menu-section containing the 17th command starting to count from the current menu section...
A transparent way to open virtual keyboard during FCN could be the usual tap on right screen boundary.
Useless to say, that, having this feature, a modified FCN+ containing really all commands of plus42 would be a dream.

E Lye

unread,
Apr 1, 2026, 2:49:19 AM (2 days ago) Apr 1
to Free42 & Plus42
Why not just use "this is a comment" and not bother with SKIP?
I have not encountered any complications and it doubles up as 
"NOP" as well.
ireXfc.png

Thomas Okken

unread,
Apr 1, 2026, 3:48:28 AM (2 days ago) Apr 1
to Free42 & Plus42
On Wednesday, April 1, 2026 at 8:49:19 AM UTC+2 E Lye wrote:
Why not just use "this is a comment" and not bother with SKIP?
I have not encountered any complications and it doubles up as 
"NOP" as well.

There are two downsides to that: It is limited to 15 characters per line, and it overwrites the contents of the ALPHA register.

Using SKIP avoids the side effects of "comment" or XSTR "comment", but it does lead to messy-looking code.

A proper COMMENT function would be cleaner. Supporting it would add complexity to the program storage format, but it would work a lot better as an actual comment. I'm not happy about the many ramifications behind the scenes, but I can't deny it would be useful. I am considering adding it in a future release.
Reply all
Reply to author
Forward
0 new messages