Loading [MathJax]/extensions/Safe.js


Post Reply 
HP-42S / Free42 Extension for Visual Studio Code
11-04-2018, 04:14 PM
Post: #1
HP-42S / Free42 Extension for Visual Studio Code
An Extension for editing HP-42S / Free42 code in Visual Studio Code has been made available in the Visual Studio Marketplace: https://marketplace.visualstudio.com/ite...42s-free42

I haven't tried it myself, but the previews look promising.

Written by Jochen Heilingbrunner; requires VSC 1.27 or later; free download.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-04-2018, 08:08 PM
Post: #2
RE: HP-42S / Free42 Extension for Visual Studio Code
Quote:Please welcome our newest member, Heilingbrunner
Find all posts by this user
Quote this message in a reply
11-04-2018, 10:47 PM
Post: #3
RE: HP-42S / Free42 Extension for Visual Studio Code
This looks great!

The extension appears and installs ok in my Visual Studio Code (the free editor) on my Mac but I'm not getting the promised behaviours. I've tried both *.hp42 and *.free42 file extensions but only the latter does any syntax highlighting at all, but not the fancy HP42 syntax completion. And the formatting menu is not appearing either. I've tried restarting visual studio code. Has anyone gotten this working?
Find all posts by this user
Quote this message in a reply
11-04-2018, 11:33 PM (This post was last modified: 11-04-2018 11:35 PM by Sylvain Cote.)
Post: #4
RE: HP-42S / Free42 Extension for Visual Studio Code
Tried it on Visual Studio Code (1.28.2) over macOS High Sierra (10.13.6).
Installation, color coding, syntax completion & formatting works perfectly.
I am not able to encode or decode the program, I do not see the options in any menu or contextual menu.
I have read the how-to, but it is not clear for me how you do it and unfortunately the screen capture is in German.
Some help will be appreciated, thank you!
Sylvain
Find all posts by this user
Quote this message in a reply
11-05-2018, 12:24 AM
Post: #5
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-04-2018 10:47 PM)tcab Wrote:  I've tried both *.hp42 and *.free42 file extensions but only the latter does any syntax highlighting at all
The suffix .hp42s works for me.

Quote:And the formatting menu is not appearing either.

Try: right click
Format Document ⌥ ⇧ F

(11-04-2018 11:33 PM)Sylvain Cote Wrote:  I am not able to encode or decode the program, I do not see the options in any menu or contextual menu.

Try: right click
Command Palette… ⇧ ⌘ P

Start typing: encode code

The following should show up:
hp42s/free42: Encode Code

HTH
Thomas
Find all posts by this user
Quote this message in a reply
11-05-2018, 01:20 AM
Post: #6
RE: HP-42S / Free42 Extension for Visual Studio Code
@Thomas - thanks for those tips. Indeed it looks like the file extension has to be .hp42s not .hp42 (looks like a typo in the plugin documentation). Raw exporting works in the way you say, too.

Formatting works and strips line numbers etc. It would be nice, I think, to have a command to add line numbers back. I remember, in the past, I had trouble pasting RPN code into Free42 unless it had line numbers - even if all the line numbers were 00. Though... I just tried again without line numbers and things pasted ok into Free42. Hmm.
Find all posts by this user
Quote this message in a reply
11-05-2018, 06:05 AM (This post was last modified: 11-05-2018 01:10 PM by Thomas Klemm.)
Post: #7
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-05-2018 01:20 AM)tcab Wrote:  It would be nice, I think, to have a command to add line numbers back.

This command inserts line numbers to the files:
Code:
perl -i~ -ne 'printf "%02d $_", $.' <files ...>

The original files are renamed to contain a tilde (~) as suffix.
This can be changed of course. See perl -h:
Code:
  -i[extension]     edit <> files in place (makes backup if extension supplied)

If you use that command often you can make it a function and add it e.g. to your ~/.bash_profile:
Code:
function add_line_numbers ()
{
    perl -i~ -ne 'printf "%02d $_", $.' "$@"
}

Use %03d instead of %02d if you prefer 3-digit numbers.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-05-2018, 10:04 AM
Post: #8
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-05-2018 01:20 AM)tcab Wrote:  It would be nice, I think, to have a command to add line numbers back. I remember, in the past, I had trouble pasting RPN code into Free42 unless it had line numbers - even if all the line numbers were 00. Though... I just tried again without line numbers and things pasted ok into Free42. Hmm.

That was fixed earlier this year:

Quote:2018-01-07: release 2.0.10

* Program Paste without line numbers didn't handle certain numbers,
specifically, those that started with a digit and didn't consist of only
digits. Fixed.

2018-01-07: release 2.0.9

* Program Paste no longer requires line numbers.
[...]
Visit this user's website Find all posts by this user
Quote this message in a reply
11-05-2018, 10:52 AM (This post was last modified: 11-05-2018 10:53 AM by Sylvain Cote.)
Post: #9
RE: HP-42S / Free42 Extension for Visual Studio Code
Thanks Thomas,

Perl call from command line and from .profile worked, same thing for Palette / encode code.
It does not seems to, but does it have a way to decode a hex or raw file ?

Best regards,

Sylvain
Find all posts by this user
Quote this message in a reply
11-05-2018, 01:01 PM
Post: #10
RE: HP-42S / Free42 Extension for Visual Studio Code
Hello Everybody,

i am happy to see you tried my extension.

I had thought about decoding raw code to text back again, but i think the most use case is encoding from code to raw format.

Jochen
Find all posts by this user
Quote this message in a reply
11-05-2018, 01:08 PM
Post: #11
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-05-2018 10:52 AM)Sylvain Cote Wrote:  It does not seems to, but does it have a way to decode a hex or raw file ?

I don't think so. But you can use this online decoder.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-07-2018, 09:23 AM
Post: #12
RE: HP-42S / Free42 Extension for Visual Studio Code
I have two questions:

1. Why do we need line numbers in the code ?
The VSC editor already shows line numbers.

2. Why is the last ending END command ignored in the { <size>-Byte Prgm } display, but the raw file has three byte more ?
Find all posts by this user
Quote this message in a reply
11-07-2018, 04:41 PM
Post: #13
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-07-2018 09:23 AM)Heilingbrunner Wrote:  Why do we need line numbers in the code ?

While editing a file in vscode I don't care about line numbers.
The same holds if I load a .raw file into an emulator.
However when I enter a program manually into a real calculator it helps to have line numbers.
If I miss a command it helps to find the error.

Quote:The VSC editor already shows line numbers.

True. But when the x-Byte Prgm line is generated it is off by one.

HP-42S
Code:
00 { 20-Byte Prgm }
01▸LBL "TREE"
02 X<>Y
03 -
04 LASTX
05 X↑2
06 1ᴇ4
07 +
08 SQRT
09 ÷
10 ×
11 END

Visual Studio Code
Code:
 1    { 23-Byte Prgm }
 2    LBL "TREE"
 3    X<>Y
 4    -
 5    LASTX
 6    X↑2
 7    1ᴇ4
 8    +
 9    SQRT
10    ÷
11    ×
12    END

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-07-2018, 05:21 PM
Post: #14
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-07-2018 09:23 AM)Heilingbrunner Wrote:  Why is the last ending END command ignored in the { <size>-Byte Prgm } display

That's what the real HP-42S does. It is strange, since the END is, in fact, a part of the program... but that's the way it is.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-07-2018, 09:52 PM
Post: #15
RE: HP-42S / Free42 Extension for Visual Studio Code
Ok, i will add a command for the line numbers.
Find all posts by this user
Quote this message in a reply
11-09-2018, 09:24 AM
Post: #16
RE: HP-42S / Free42 Extension for Visual Studio Code
Hi,

in version 0.0.4, i improved the document formatter. It inserts/refreshes the line numbers.
The encoder although detects wrong line numbers.

Regards.
Find all posts by this user
Quote this message in a reply
11-11-2018, 09:01 AM
Post: #17
RE: HP-42S / Free42 Extension for Visual Studio Code
(11-05-2018 01:01 PM)Heilingbrunner Wrote:  I had thought about decoding raw code to text back again, but i think the most use case is encoding from code to raw format.

I can't say much about the 42s and Free42 in this regard, but for the HP-41 I use hp41uc (Leo Duran's HP41 user code compiler/decompiler) in both ways. Raw files are great for transferring programs or saving/loading programs for use with an emulator, e.g. Warren Furlow's V41. But I also like the decompiler option very much, as it generates nice program listings. Which can be posted here, for instance. There are even several formatting options.

Dieter
Find all posts by this user
Quote this message in a reply
11-16-2018, 11:18 PM (This post was last modified: 11-16-2018 11:31 PM by Heilingbrunner.)
Post: #18
RE: HP-42S / Free42 Extension for Visual Studio Code
Hi,
i read the suggestions and made some changes.
Now the extension supports multi programs in a *hp42s/*free42 file. The formatter and encoder will update the line numbers and program sizes as required for manual input on a original HP-42S (tcab). The program size calculation behaves as the original.
The next feature will be the decoder. But this will take some time.
Hope you can use it.

   

Regards.
Find all posts by this user
Quote this message in a reply
11-17-2018, 09:54 PM
Post: #19
RE: HP-42S / Free42 Extension for Visual Studio Code
Thanks for the update. However I noticed a weird behaviour when an error occurs during encoding.

Code:
LBL "TOO-LONG-FOR-A-LABEL"

Encode this to get:
Code:
00 { Error [1, 01]: Code: 'LBL "TOO-LONG-FOR-A-LABEL"'; Message: 'line number not correct' }
LBL "TOO-LONG-FOR-A-LABEL"
The message is a bit misleading.

Correct the label:
Code:
00 { Error [1, 01]: Code: 'LBL "TOO-LONG-FOR-A-LABEL"'; Message: 'line number not correct' }
LBL "SHORT"

Encode again to get:
Code:
00 { 1-Byte Prgm }
00 { 9-Byte Prgm }
LBL "SHORT"

Format to get some strange line numbering:
Code:
01 00 { 1-Byte Prgm }
02 00 { 9-Byte Prgm }
01 LBL "SHORT"


Is there an easier way to remove line numbers instead of using ⇧ ⌥ ⌘ with cursors to select a block and delete it?

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
11-18-2018, 07:58 AM (This post was last modified: 11-18-2018 08:06 AM by Heilingbrunner.)
Post: #20
RE: HP-42S / Free42 Extension for Visual Studio Code
Sorry, for that bug.

My asumption was that a program starts with a 'LBL "NAME"'. Now the extension will detect a program with a '{}' line, which will be filled with a error message or the program size.

   

In Visual Studio Code block editing is possible. A good introduction can be found at the Visual Studio Code documentation.
Find all posts by this user
Quote this message in a reply
Post Reply 




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