PARSE questions

52 views
Skip to first unread message

Andy

unread,
Mar 31, 2026, 9:52:18 PM (2 days ago) Mar 31
to Free42 & Plus42
I have a large equation and I'm interested in seeing the results of PARSE:

1.  Is it possible to view the code in "invisible directory with ID 1"?

"Note: It is possible to step into generated code, that is, programs that are created by Plus42 when it parses equations. For example, if you execute a program fragment like XSTR "A+B*C" PARSE EVAL, the PARSE will translate the equation to an RPN program, and store it in the invisible directory with ID 1, and EVAL will call that generated code, somethat like XEQ. When you SST the EVAL, you will next find yourself single-stepping the generated code."

2.  when used in a program, does XSTR have a 47 character limit (it appears to).  If so, is there a way to append more characters? 

Andy

unread,
Mar 31, 2026, 9:53:50 PM (2 days ago) Mar 31
to Free42 & Plus42
Here's the program I'm using to SST and see the results of PARSE:

00 { 63-Byte Prgm }
01 XSTR "-g*(2*m1+m2)*sin(T1)-m2*g*sin(T1-2*T2)-2*sin(T1" <---appears to be limited to 47 characters
02 PARSE
03 EVAL
04 END

Andy

unread,
Mar 31, 2026, 10:00:50 PM (2 days ago) Mar 31
to Free42 & Plus42
btw, I am pasting my text into Plus42, I still see the 50 character limit:

" Note that XSTR will only let you enter up to 50 characters when you use it interactively, but when created by pasting text, XSTR commands in programs can be up to 65535 characters long, and string objects (on the stack and in variables) don't have a length limit at all."

Andy

unread,
Mar 31, 2026, 10:15:49 PM (2 days ago) Mar 31
to Free42 & Plus42
I think I figured it out, when you say pasting XSTR, you mean to paste the entire command:  "XSTR "equation details"", that works for me and gets around the 50 character limit.

Thomas Okken

unread,
Apr 1, 2026, 3:40:55 AM (2 days ago) Apr 1
to Free42 & Plus42
On Wednesday, April 1, 2026 at 4:15:49 AM UTC+2 593...@gmail.com wrote:

I have a large equation and I'm interested in seeing the results of PARSE:

Is it possible to view the code in "invisible directory with ID 1"?

"Note: It is possible to step into generated code, that is, programs that are created by Plus42 when it parses equations. For example, if you execute a program fragment like XSTR "A+B*C" PARSE EVAL, the PARSE will translate the equation to an RPN program, and store it in the invisible directory with ID 1, and EVAL will call that generated code, somethat like XEQ. When you SST the EVAL, you will next find yourself single-stepping the generated code."

You can't CHDIR into directory 1, since it is not in the directory tree. But you can view the generated code for individual equations using the trick you just quoted. Specifically, go into PRGM mode and enter EQN.FCN → EVAL, press EXIT to leave PRGM mode, and then, with the equation in the X register, press SST.

At this point, program execution is on the first line of the generated code, and you can go into PRGM mode and view it.

when used in a program, does XSTR have a 47 character limit (it appears to). If so, is there a way to append more characters? 
[...]

I think I figured it out, when you say pasting XSTR, you mean to paste the entire command: "XSTR "equation details"", that works for me and gets around the 50 character limit.

You can paste the string into the X register, and then use CATALOG → MISC → X2LINE to insert the string into the program.

However, there is an easier way: you can use the equation editor. EQN.FCN → NEW, then enter the equation, then hit ENTER. You will then be prompted to choose how to save the equation: PLAIN inserts the equation as a regular equation, EVAL inserts an EVAL 'equation' line, and XSTR inserts the text as an XSTR line.

If you need to modify an existing equation or XSTR line, you can use EQN.FCN → EDIT.

Andy

unread,
Apr 1, 2026, 9:19:11 PM (2 days ago) Apr 1
to Free42 & Plus42
Thank you, Thomas.  I'm understanding it now.  I can use a simple program (below) and paste all the characters for line 02 in when I have complicated equations over 50 characters.  Then I exit the program mode and SST from line 00 to line 04.  Then when I go back into program mode, I see the results of PARSE (also included below to document my learnings).

Program to explore PARSE of an equation:

00 { 160-Byte Prgm }
01▸LBL "PRS"
02 XSTR "(-g*(2*M1+M2)*SIN(T1)-M2*g*SIN(T1-2*T2)-2*SIN(T1-T2)*M2*(W2^2*L2+W1^2*L1*COS(T1-T2)))/(L1*(2*M1+M2*(1-COS(2*T1-2*T2))))"
03 PARSE
04 EVAL
05 END

Hidden program created by PARSE:

00 { 142-Byte Prgm }
01 FSTART
02 RCL "g"
03 2
04 RCL "M1"
05 ×
06 RCL "M2"
07 +
08 ×
09 RCL "T1"
10 SIN
11 ×
12 +/-
13 RCL "M2"
14 RCL "g"
15 ×
16 RCL "T1"
17 2
18 RCL "T2"
19 ×
20 -
21 SIN
22 ×
23 -
24 2
25 RCL "T1"
26 RCL "T2"
27 -
28 SIN
29 ×
30 RCL "M2"
31 ×
32 RCL "W2"
33 2
34 Y↑X
35 RCL "L2"
36 ×
37 RCL "W1"
38 2
39 Y↑X
40 RCL "L1"
41 ×
42 RCL "T1"
43 RCL "T2"
44 -
45 COS
46 ×
47 +
48 ×
49 -
50 RCL "L1"
51 2
52 RCL "M1"
53 ×
54 RCL "M2"
55 1
56 2
57 RCL "T1"
58 ×
59 2
60 RCL "T2"
61 ×
62 -
63 COS
64 -
65 ×
66 +
67 ×
68 ÷
69 END
Reply all
Reply to author
Forward
0 new messages