HP Forums
(71B) FORTH questions - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: (71B) FORTH questions (/thread-20029.html)

Pages: 1 2 3 4 5


(71B) FORTH questions - floppy - 05-29-2023 04:13 PM

Hello,
I have transfered a FORTH file into a virtual drive.
Code:
cat PERE12.SRC | textlif PERE12 | lifput /media/user/ILPERSTO/HDRIVE16.DAT
Now, how to get that file into the FORTH environment on EMU71 and start the words in it? (PERE12 and TEST words).
So far understood, the commands for retrieving a file must be given in relation with the BASICX command. I have tested this with " ASSIGN IO ' :TV,:T1,:MS,:T2'" BASICX .. which seems to have lost any relation with the setup since VIDEO80 is nomore showing anything.
Any advice how to retrieve a file in a virtual drive from such FORTH setup (see screen copy) is welcome.. and how to start the program.


RE: (71B) FORTH questions - rprosperi - 05-29-2023 04:52 PM

If you have text file PERE12 on a LIF volume HDRIVE16.DAT mounted as :TAPE(1) you can do this:

COPY PERE12:TAPE(1) TO :MAIN
FORTH
LOADF " PERE12"
(note the space following the initial double quote)

This will load the text file into 71B Forth. As Sylvain noted, while most Forth systems load successive "screens" via the LOAD command, on 71B Forth, the LOADF (meaning LOAD from File) is used to read from a text file.

If you get no errors, then the words have been successfully loaded into the current dictionary, and are now available to use interactively, or to build into programs.

Note that if you get an error while processing the 6th Forth word and it aborts, the initial 5 words have still been added to your dictionary and likely should be removed before you try again, after correcting the problem in the failed word. One way to make that easier is to start your file with a 'placeholder' word such as

: PLACE ;

and then after it fails you can simply use

FORGET PLACE

to remove all the words starting from PLACE to the end of the dictionary.


RE: (71B) FORTH questions - floppy - 05-29-2023 07:58 PM

Thanks. I made few progress.

Under FORTH prompt (for recovery of the lost display)
" RESET HPIL" BASICX
" CONTROL ON" BASICX
" RESTORE IO" BASICX
“ DISPLAY IS : DISPLAY” BASICX
“ PRINTER IS : PRINTER” BASICX

“ CAT :HDRIVE1” BASICX
.. NAME S TYPE LEN DATE TIME
.. PERE12 TEXT 768 05/29/23 17:16 (see attached code)

"COPY PERE12:HDRIVE1 TO MAIN:" BASICX
.. ERR: Invalid Filespec

BYE (it goes back to BASIC prompt)
> COPY PERE12:HDRIVE1 (which is linked to HDRIVE16.DAT)

FORTH (it goes to the FORTH prompt)
LOADF " PERE12”
.. ERR: Invalid Filespec (now I have to search what is going on here)

So far achieved:
- listing of HDRIVE1 content (file HDRIVE16.DAT)
- uploading TXT file into the HP71B

Code:
3.1415926535897932e FCONSTANT PINB
FVARIABLE B
FVARIABLE A
FVARIABLE TV
1.0e FVARIABLE R
DECIMAL
: PERE12 B STO ." Param B:  " F. CR X=0? IF F+ 4.0e F*
." ELLIPSE PERIM= " F. EXIT THEN X<>Y ." Param A:  " F. CR A
STO X=0? IF F+ 4.0e F* ." ELLIPSE PERIM= " F. EXIT THEN FENTER
F* X<>Y FENTER F* F+ TV STO FDROP 1.0e R F! FDROP BEGIN A RCL
FENTER B RCL FENTER RDN F* SQRT B STO RDN F- CHS R RCL 2.0e F*
R STO FDROP LASTX F/ A RCL X<>Y F- A STO FDROP B RCL X<>Y LASTX
X^2 R RCL F* TV RCL F- CHS TV STO FDROP X=Y? UNTIL 1/X TV RCL F*
PINB F* ." ELLIPSE PERIM= " F. CR ;
: TEST 3.0e 11.0e PERE12 ;



RE: (71B) FORTH questions - rprosperi - 05-30-2023 12:29 AM

A file specifier for 71B is of the form NAME:DEVICE, where NAME is the normal filename and DEVICE is either :MAIN, :PORT(n), or :HP-IL_Device (such as HDRIVE1). There are other possibilities, but these are the core choices. Note you user "MAIN:" which is not legal.

The 71B is NOT Linux- or PC-like at all when it comes to files and storage devices.

This command is not complete:

> COPY PERE12:HDRIVE1 (which is linked to HDRIVE16.DAT)

you need to specify where to copy TO. These are options:

COPY PERE12:HDRIVE1 TO :MAIN (will retain original name)

COPY PERE12:HDRIVE1 TO SOME_NAME:MAIN (will copy to file with new name)

*** After you copy the file, CAT it to make sure it is present and of type "TEXT" ***


RE: (71B) FORTH questions - floppy - 05-30-2023 02:07 PM

>DESTROY ALL
>COPY PERE12:HDRIVE1 TO :MAIN
HPIL ERR: File Exists
>CAT ALL
NAME S TYPE LEN DATE TIME PORT
FORTHRAM FORTH 2927 05/01/23 21:23
>COPY PERE12:HDRIVE1 TO PEREL:MAIN
>CAT ALL
NAME S TYPE LEN DATE TIME PORT
FORTHRAM FORTH 2927 05/01/23 21:23
.. weird.. something is uploaded, then cannot be uploaded again.. and CAT ALL dont see anything.
Looks like I am stuck with basic commands on EMU71.


RE: (71B) FORTH questions - Valentin Albillo - 05-30-2023 03:05 PM

(05-30-2023 02:07 PM)floppy Wrote:  .. weird.. something is uploaded, then cannot be uploaded again.. and CAT ALL dont see anything.

I don't know about the FORTH environment but in the BASIC environment CAT ALL initially only shows the data for the first file in the file chain, and you must press the [CURSOR DOWN] key repeatedly to see additional files, or [CURSOR UP] thereafter to redisplay the data for the previous file(s).

Have you tried using those cursor keys after excuting CAT ALL in the FORTH environment ? It might work ...

V.


RE: (71B) FORTH questions - floppy - 05-30-2023 04:05 PM

(05-30-2023 03:05 PM)Valentin Albillo Wrote:  
(05-30-2023 02:07 PM)floppy Wrote:  .. weird.. something is uploaded, then cannot be uploaded again.. and CAT ALL dont see anything.

I don't know about the FORTH environment but in the BASIC environment CAT ALL initially only shows the data for the first file in the file chain, and you must press the [CURSOR DOWN] key repeatedly to see additional files, or [CURSOR UP] thereafter to redisplay the data for the previous file(s).

Have you tried using those cursor keys after excuting CAT ALL in the FORTH environment ? It might work ...

V.
You are the boss. The files are there. See screen copy in the attachment.

By using PLIST as recommended there https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv021.cgi?read=248404 , we have
> PLIST PERE12 (into ILPER)
Code:
3.1415926535897932e FCONSTANT PINBFVARIABLE BFVARIABLE AFVARIABLE TV1.0e FVARIABLE RDECIMAL: PERE12 B STO ." Param B:  " F. CR X=0? IF F+ 4.0e F*." ELLIPSE PERIM= " F. EXIT THEN X<>Y ." Param A:  " F. CR ASTO X=0? IF F+ 4.0e F* ." ELLIPSE PERIM= " F. EXIT THEN FENTERF* X<>Y FENTER F* F+ TV STO FDROP 1.0e R F! FDROP BEGIN A RCLFENTER B RCL FENTER RDN F* SQRT B STO RDN F- CHS R RCL 2.0e F*R STO FDROP LASTX F/ A RCL X<>Y F- A STO FDROP B RCL X<>Y LASTXX^2 R RCL F* TV RCL F- CHS TV STO FDROP X=Y? UNTIL 1/X TV RCL F*PINB F* ." ELLIPSE PERIM= " F. CR ;: TEST 3.0e 11.0e PERE12 ;

The format looks a bit screwed up. Now it has to be reformatted/uploaded into FORTH. More to be done..


RE: (71B) FORTH questions - floppy - 05-30-2023 04:39 PM

A try to..
> DESTROY PEREL
ERR:Excess Chars
Looks like EMU71 got an hickup with the file (no deletion in place).


RE: (71B) FORTH questions - rprosperi - 05-30-2023 07:42 PM

(05-30-2023 04:39 PM)floppy Wrote:  A try to..
> DESTROY PEREL
ERR:Excess Chars
Looks like EMU71 got an hickup with the file (no deletion in place).

DESTROY is for removing variables

PURGE is for removing files

Your goal of creating some kind of IDE for using Forth on the 71B is indeed interesting and ambitious, but I'd suggest you learn how to use the 71B a bit more before diving into esoterica. Read the manuals, they're pretty good.

Or, even easier, start with Joe Horn's book "HP-71 BASIC Made Easy"; here's a PDF in German:

https://literature.hpcalc.org/items/1632


RE: (71B) FORTH questions - floppy - 05-31-2023 06:50 AM

Thanks.

> PURGE PEREL
made it. All FORTH AND HPIL AND BASIC books are on the table (PURGE was not identified so far; now thanks you it is).

Now I will try to upload the TXT file into the HP71B via DOSLINK (some hints from JF could be found there https://www.hpmuseum.org/forum/thread-11585.html ) since the currently applied method (use of lifutils etc.) screwed up the TXT format in Post #3 (change from maximum 64 letters per line, to 1 line file format. Perhaps coming from a linux environment/editor).

Any advice how to upload properly the PERE12 program, see Post #3, into HP71B (first EMU71) is welcome.

I am trying (no success so far)

a) to use linux commands like
Code:
unix2dos -v PERE12.SRC
for changing the format.
https://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/

b) https://www.hpmuseum.org/forum/thread-7868-post-70154.html#pid70154
Download alifhdr32 from http://hp.giesselink.com/Pcuti/alifhdr32.zip
Unzip the zip archive
Execute WINE "ALIFHDR PERE12.SRC PERE12.DAT /T" on a linux PC
Open ILPer and connect to the EMU71
In the DosLink "In" edit field select PERE12.DAT
On the EMU71, execute "COPY :DOS"
.. it hangs "HP-IL SCOPE" show continuous messages ".. SDA .."


RE: (71B) FORTH questions - rprosperi - 05-31-2023 12:18 PM

(05-31-2023 06:50 AM)floppy Wrote:  On the EMU71, execute "COPY :DOS"
.. it hangs "HP-IL SCOPE" show continuous messages ".. SDA .."

The command should be:

COPY :DOSLINK TO FILENAME

On the 71B you MUST always include the word TO and also a target. In this case, you need to specify a filename as the original is not preserved when using DOSLINK.


RE: (71B) FORTH questions - floppy - 05-31-2023 12:42 PM

Thanks.

in BASIC prompt "[B]>"
[B]>COPY :DOSLINK TO PERE12
[B]>CAT ALL (file there)
[B]>PLIST PERE12 (.. then copy from ILPER window)
Code:
3.1415926535897932e FCONSTANT PINBFVARIABLE BFVARIABLE AFVARIABLE TV1.0e FVARIABLE RDECIMAL: PERE12 B STO ." Param B:  " F. CR X=0? IF F+ 4.0e F*." ELLIPSE PERIM= " F. EXIT THEN X<>Y ." Param A:  " F. CR ASTO X=0? IF F+ 4.0e F* ." ELLIPSE PERIM= " F. EXIT THEN FENTERF* X<>Y FENTER F* F+ TV STO FDROP 1.0e R F! FDROP BEGIN A RCLFENTER B RCL FENTER RDN F* SQRT B STO RDN F- CHS R RCL 2.0e F*R STO FDROP LASTX F/ A RCL X<>Y F- A STO FDROP B RCL X<>Y LASTXX^2 R RCL F* TV RCL F- CHS TV STO FDROP X=Y? UNTIL 1/X TV RCL F*PINB F* ." ELLIPSE PERIM= " F. CR ;: TEST 3.0e 11.0e PERE12 ;
[B]>FORTH

in FORTH prompt "[F]\"
"[F]\"LOADF " PERE12"
..ERR:Invalid Filespec

looks like no success so far.


RE: (71B) FORTH questions - J-F Garnier - 05-31-2023 01:00 PM

(05-31-2023 12:42 PM)floppy Wrote:  in BASIC prompt "[B]>"
[B]>COPY :DOSLINK TO PERE12
[B]>CAT ALL (file there)
[B]>PLIST PERE12 (.. then copy from ILPER window)
Code:
3.1415926535897932e FCONSTANT ... (looong) ... ;

You created the text file on a Linux system, right?
I assume that you are quite experimented in Linux. Does the LF- vs CR/LF-terminated line issue sound familiar to you?
I'm suspecting this kind of thing.

Apparently you succeeded to load the file correctly above:
(05-29-2023 07:58 PM)floppy Wrote:  So far achieved:
- listing of HDRIVE1 content (file HDRIVE16.DAT)
- uploading TXT file into the HP71B

Code:
3.1415926535897932e FCONSTANT PINB
FVARIABLE B
FVARIABLE A
FVARIABLE TV
1.0e FVARIABLE R
DECIMAL
: PERE12 B STO ." Param B:  " F. CR X=0? IF F+ 4.0e F*
." ELLIPSE PERIM= " F. EXIT THEN X<>Y ." Param A:  " F. CR A
STO X=0? IF F+ 4.0e F* ." ELLIPSE PERIM= " F. EXIT THEN FENTER
F* X<>Y FENTER F* F+ TV STO FDROP 1.0e R F! FDROP BEGIN A RCL
FENTER B RCL FENTER RDN F* SQRT B STO RDN F- CHS R RCL 2.0e F*
R STO FDROP LASTX F/ A RCL X<>Y F- A STO FDROP B RCL X<>Y LASTX
X^2 R RCL F* TV RCL F- CHS TV STO FDROP X=Y? UNTIL 1/X TV RCL F*
PINB F* ." ELLIPSE PERIM= " F. CR ;
: TEST 3.0e 11.0e PERE12 ;
So why doesn't it work anymore?


And to save you another unsuccessful attempt, this is wrong:
Quote:n FORTH prompt "[F]\"
"[F]\"LOADF " PERE12"
..ERR:Invalid Filespec
FORTH doesn't use postfix parameters. This is " filespec" LOADF .

J-F


RE: (71B) FORTH questions - floppy - 05-31-2023 02:25 PM

Experienced in my linux? not really. I am an user.
"the LF- vs CR/LF-terminated line issue sound familiar to you?" no. I will search what this mean.
" PERE12" LOADF
.. bring the message ERR:Data Type.

Lets explain: the PERE12 file in FORTH with the correct format (see the previous post where the line with of the file is maximum 64 characters; NOT the 1 line file) was done in an gforth IDE on a Linux PC with 64bits for simulating the HP71B Forth commands.
Why I was doing this? I was using a wide screen, extensive debugging, commenting possible.. a bit like the CC41 from Craig BLADOW but here for an HP71B FORTH
= the working file was not created in an HP71B but in a FORTH simulator for HP71B; this is the reason of my actions here where I now try to upload a (supposed working) HP71B FORTH file into EMU71 for a double check it still works there. Then next step will be I check in an HP71B with Forth module.
= "debugging" my "debugging environment on PC" for HP71B Forth programming on a PC.

(I know.. perhaps me and 5 other people on this planet could be interested..).


RE: (71B) FORTH questions - J-F Garnier - 05-31-2023 04:00 PM

(05-31-2023 02:25 PM)floppy Wrote:  Experienced in my linux? not really. I am an user.
"the LF- vs CR/LF-terminated line issue sound familiar to you?" no. I will search what this mean.

Just ask G..gle:
Quote:CRLF stands for Carriage Return Line Feed, and LF stands for Line Feed. CRLF is a two-character sequence used to indicate the end of a line of text in a file. It is represented by the characters CR (carriage return) and LF (line feed). CRLF is used in Windows-based systems, while LF is used in Unix-based systems.

Quote:" PERE12" LOADF
.. bring the message ERR:Data Type.

Some progress ... now your file is read :-)


Just try to enter (in FORTH env.):
1.0e
ERR:Data Type

I don't understand (and the 71B-FORTH too, obviously) the meaning of that little 'e'.

So many incompatibilities to solve... part of the fun I assume :-)

J-F


RE: (71B) FORTH questions - floppy - 05-31-2023 07:55 PM

+1. Program now loaded in the HP71B and in debugging phase which mean my debugger on the PC has to be improved because it allowed a buggy program to work on the PC but dont work on the HP71B.
..
Code:
I don't understand (and the 71B-FORTH too, obviously) the meaning of that little 'e'.
that came from the debugger on the PC (another Forth) where floats are written with 1.0e or 1.0e0 or 1.0E+10 or..: now changing to E0 made it in the HP71B (float 1. works on HP71B but dont work on the debugger in the PC).

Update: program work. Few messages appear regarding internal parameters. Seems not to disturb much so far. See screen copy below.

More to be done (testing the PC debugger with more programs, make automatic the transfer to EMU71, test on HP71B). Whatever that was my first FORTH program.

The output to ILPER with
[B]>COPY :DOSLINK
[B]>PLIST PERE12
looks a bit weird, but whatever it works.
Here below is a cleaned version of the print in ILPER with introduced <cr> and blanks in the post
Code:
3.14159265359E0 FCONSTANT PINB
FVARIABLE B
FVARIABLE A
FVARIABLE TV
1.0E0 FVARIABLE R
DECIMAL
: PERE12 B STO ." Param B:  " F. CR X=0? IF F+ 4.0E0 F* ." ELLIPSE PERIM= " F. EXIT THEN X<>Y ." Param A:  " F. CR ASTO X=0? IF F+ 4.0E0 F* ." ELLIPSE PERIM= " F. EXIT THEN FENTER F* X<>Y FENTER F* F+ TV STO FDROP 1.0E0 R STO FDROP BEGIN A RCL FENTER B RCL FENTER RDN F* SQRT B STO RDN F- CHS R RCL 2.0E0 F* R STO FDROP LASTX F/ A RCL X<>Y F- A STO FDROP B RCL X<>Y LASTX X^2 R RCL F* TV RCL F- CHS TV STO FDROP X=Y? UNTIL 1/X TV RCL F* PINB F* ." ELLIPSE PERIM= " F. CR ;
: TEST 3.0E0 11.0E0 PERE12 ;



RE: (71B) FORTH questions - rprosperi - 05-31-2023 10:26 PM

(05-31-2023 01:00 PM)J-F Garnier Wrote:  And to save you another unsuccessful attempt, this is wrong:
Quote:n FORTH prompt "[F]"
"[F]"LOADF " PERE12"
..ERR:Invalid Filespec
FORTH doesn't use postfix parameters. This is " filespec" LOADF .

That's my fault; in a post above I suggested to use this in postfix format.


RE: (71B) FORTH questions - floppy - 06-15-2023 07:34 PM

what would be a similar word to "time&date" (gforth) ?
The HP71B IDS V1 Chapter 15.6 show few informations and I suppose something can be extracted from an address. Any advice is welcome (I have the HP71B Forth/Assembler and no CLOCK word from the translator; BASIC functions? prohibited .. ;-)


RE: (71B) FORTH questions - rprosperi - 06-16-2023 03:22 AM

(06-15-2023 07:34 PM)floppy Wrote:  what would be a similar word to "time&date" (gforth) ?
The HP71B IDS V1 Chapter 15.6 show few informations and I suppose something can be extracted from an address. Any advice is welcome (I have the HP71B Forth/Assembler and no CLOCK word from the translator; BASIC functions? prohibited .. ;-)

I'm not sure what you mean by "BASIC functions? prohibited", but you can try this:

" TIME$" BASIC$ which returns a string with the current time to the stack, which you can then display with the TYPE command.


RE: (71B) FORTH questions - floppy - 06-16-2023 01:53 PM

(06-16-2023 03:22 AM)rprosperi Wrote:  
(06-15-2023 07:34 PM)floppy Wrote:  what would be a similar word to "time&date" (gforth) ?
The HP71B IDS V1 Chapter 15.6 show few informations and I suppose something can be extracted from an address. Any advice is welcome (I have the HP71B Forth/Assembler and no CLOCK word from the translator; BASIC functions? prohibited .. ;-)

I'm not sure what you mean by "BASIC functions? prohibited", but you can try this:

" TIME$" BASIC$ which returns a string with the current time to the stack, which you can then display with the TYPE command.
And with no BASIC? I am searching the memory area where the time counter is placed.