HP Forums
Load HP50 program to NewRPL machine? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Load HP50 program to NewRPL machine? (/thread-14427.html)



Load HP50 program to NewRPL machine? - Klaus - 01-27-2020 01:52 PM

Hello community,
I have written several extensive programs in UserRPL for the 50g. I want to take advantage of the higher speed and accuracy of NewRPL. Is there a way to transfer them to the NewRPL-HP50 after some necessary modifications? It would be a "slave labour" to type this manuel one.
Greeting Klaus


RE: Load HP50 program to NewRPL machine? - Claudio L. - 01-27-2020 06:11 PM

(01-27-2020 01:52 PM)Klaus Wrote:  Hello community,
I have written several extensive programs in UserRPL for the 50g. I want to take advantage of the higher speed and accuracy of NewRPL. Is there a way to transfer them to the NewRPL-HP50 after some necessary modifications? It would be a "slave labour" to type this manuel one.
Greeting Klaus
It's actually quite simple:
Use your favorite text editor. The trigraph characters are not supported, newRPL is full Unicode compliant so you need to do Search/Replace on all trigraphs to replace with proper Unicode symbols (your favorite text editor must be able to save the text as UTF-8).

Using newRPL Desktop simulator, you can simply copy the text from your text editor to the clipboard and paste it into the stack. There's 2 options in the menu: Paste (which would paste the text to the stack) and Paste&Compile which would attempt to immediately compile the code.

Once you have it working, a USB cable and you can easily send it to the real calc. Or you can also save the objects to a file and put it on an SD card, but I think USB is easier.


RE: HP50-Programm auf NewRPL-Maschine laden? - Klaus - 02-01-2020 09:12 AM

(01-27-2020 06:11 PM)Claudio L. Wrote:  
(01-27-2020 01:52 PM)Klaus Wrote:  Hello community,
I have written several extensive programs in UserRPL for the 50g. I want to take advantage of the higher speed and accuracy of NewRPL. Is there a way to transfer them to the NewRPL-HP50 after some necessary modifications? It would be a "slave labour" to type this manuel one.
Greeting Klaus
It's actually quite simple:
Use your favorite text editor. The trigraph characters are not supported, newRPL is full Unicode compliant so you need to do Search/Replace on all trigraphs to replace with proper Unicode symbols (your favorite text editor must be able to save the text as UTF-8).

Using newRPL Desktop simulator, you can simply copy the text from your text editor to the clipboard and paste it into the stack. There's 2 options in the menu: Paste (which would paste the text to the stack) and Paste&Compile which would attempt to immediately compile the code.

Once you have it working, a USB cable and you can easily send it to the real calc. Or you can also save the objects to a file and put it on an SD card, but I think USB is easier.


Perfect! Works wonderfully. Great job. I look forward to further development.
Greeting Klaus


RE: Load HP50 program to NewRPL machine? - erazor - 03-24-2020 12:49 PM

Regarding the replacement of digraphs:

Users of Sublime Text can use my custom command:
Code:

import sublime
import sublime_plugin

class NewrplCommand(sublime_plugin.TextCommand):
    def replace_region(self, edit, region):
        if not region.empty():
            string = self.view.substr(region)
            string = string.replace('<<', '«')
            string = string.replace('>>', '»')
            string = string.replace('->', '→')
            self.view.replace(edit, region, string)

    def replace_selections(self, view, edit):
        for region in self.view.sel():
            self.replace_region(edit, region)

    def replace_buffer(self, view, edit):
        region = sublime.Region(0, self.view.size())
        self.replace_region(edit, region)

    def run(self, edit):
        # check if something is selected
        count = sum(1 for _ in self.view.sel())
        if count == 0: # Should not happen
            self.replace_buffer(self.view, edit)
        elif count == 1:
            # Check if first and only element is just cursor
            region = next(iter(self.view.sel()))
            if region.empty():
                self.replace_buffer(self.view, edit)
            else:
                self.replace_selections(self.view, edit)
        else:
            self.replace_selections(self.view, edit)
This code can be stored as "newrpl.py" in The Packages/User folder.

Activation can be done with a key binding like this one:
Code:
{"keys": ["ctrl+t"], "command": "newrpl"}

The command uses the whole buffer if no selections exist, else replacement is only made in selections.
An improvement would be to only replace outside of strings when using the whole buffer.
Hope this helps someone.