I need to manipulate some strings in UserRPL on a HP 49g+. Particulary I
need to decompose a string in tokens using different separators. In
C/Java/C# I would used a strtok function or a string tokenizer. Which is the
best way to get the result using UserRPL?
Are there some resources/tutorials about string manipulation in UserRPL?
Sorry for the simple questions but I just bought the calculator last week (I
came from an old HP-32S).
Massimo Santin
> I need to manipulate some strings in UserRPL
The commands in MENU(62) == 62 MENU
are pretty much all there is in UserRPL
(plus, you can use a list to collect a group of separate strings)
> Particulary I need to decompose a string in tokens
> using different separators.
With a little luck, some built-in ROM function(s)
might turn out to be of help, or...
> In C/Java/C# I would used a strtok function or a string tokenizer.
> Which is the best way to get the result using UserRPL?
"Go directly to HPGCC -- do not draw a UserRPL card" :)
> I came from an old HP-32S
Those don't get "old" -- just more valuable every day :)
[r->] [OFF]
Thank you!
>> In C/Java/C# I would used a strtok function or a string tokenizer.
>> Which is the best way to get the result using UserRPL?
>
>"Go directly to HPGCC -- do not draw a UserRPL card" :)
Il will try for sure, but now I want to begin with the base. What about
SysRPL?
>> I came from an old HP-32S>
>
>Those don't get "old" -- just more valuable every day :)
I'm a proud owner of an old HP-34C, too. My first programmable thing (when I
was seventeen)! That calculator changed my life and now I'm one of the
owners of a company specialized in system integration. Thanks HP-34C!
> [r->] [OFF]
:-)
Bye
Massimo Santin
> What about SysRPL?
When I was a kid, I'd sometimes dream
that I could reach inside my body
and mess around with all the organs.
Of course, there was the concern
that any mistake poking around in there could be harmful.
Well, that wasn't real -- but now I've got SysRPL instead :)
There are later and more voluminous third-party manuals
about SysRPL, but the following very basic and brief,
yet concentrated early plain text documents
contain most of what I've ever learned about SysRPL
(one day I might actually open and read Donnelly's book, too :)
By Bill Wickes & HP [November 1991]
http://www.hpcalc.org/details.php?id=1743
http://www.hpcalc.org/hp48/docs/programming/rplman.zip
By Mika Heiskanen [September 1993]
(type VER on HP49/50 series and you'll still see his name)
http://www.hpcalc.org/details.php?id=1782
http://www.hpcalc.org/hp48/programming/entries/ent_srt.zip
Who (and where) is Bill Wickes?
http://www.hpcalc.org/hp48/docs/columns/alladdup.html
http://www.newscientist.com/article/dn8454.html
http://www.humanproductivitylab.com/archive_blogs/2006/04/07/hp_halo_covered_by_san_diego_u.php
"Make backups first"
[or use an emulator, for instant recovery from TTRMs :]
[r->] [OFF]
Ciao Massimo.
I fully agree with the hints John already gave (how could I
disagree ;-)
I dare to advise also Eduardo Kalinowski and Carsten Dominik's book:
"Programming in System RPL (PDF) 2nd Edition"
that you can find - of course - at:
http://www.hpcalc.org/hp49/docs/programming/progsysrpl_pdf.zip
and is presented as the...
..."Second edition of the free on-line book "Programming in System
RPL", a 640-page tutorial and reference for System RPL programmers.
This second edition has many improvements and describes new features
present in the HP49G calculator. In Adobe PDF format. By Eduardo M.
Kalinowski and Carsten Dominik"
I'm currently reading it (in my spare time) and, in my opinion, it is
thorough and well-written enough for a "SysRPL-newcomer" like myself.
I've already printed out a copy of RPLman as well, anyway, and
scheduled to go through it just after EK&CD book :-)
Hope this helps.
Ciao.
Giancarlo
Also be aware of the MATCH and | (where) functions: with a bit of
creativity you might be able to make your strings look like algebraic
expressions in which case the MATCH functions provide a great deal of
power in matching, sub-expression extraction and replacement etc. all
done at sysRPL speed.
Regards,
--
Bruce Horrocks
Surrey
England
(bruce at scorecrow dot com)
I just started to read the RPLMAN document and I like it. I like the
"theoretical" introduction, too.
And you can be sure that I will use an emulator and make some backup of my
calculator.
Thank you.
Massimo Santin
I downloaded the book and it seems very complete but I decided to go to the
RPLMAN way before to read it. As I told in my answer to John H. Meyers I
appreciate the theoretical background of RPLMAN. After this I will read
"Programming in System RPL (PDF) 2nd Edition".
Thank you. Grazie.
Massimo Santin
MAWK is a great library for string manipulation:
http://www.hpcalc.org/details.php?id=4254
Hope this helps
- Carsten
> I need to manipulate some strings in UserRPL on a HP 49g+.
> Particularly I need to decompose a string in tokens
> using different separators.
> In C/Java/C# I would used a strtok function or a string tokenizer.
The supported entry points "GetNextToken" and "getmatchtok"
would appear to exist for some such similar purpose,
for use by the UserRPL/Algebraic compilers,
but the only info I have seen about them is this,
from Mika's ultra-condensed notes:
GetNextToken ( hxs-mask $ #start --> hxs-mask $ #next $token )
getmatchtok ( hxs-mask $ #loc $_tok --> hxs-mask $ #next $match )
Using Nosy, you can find where these are called within ROM,
and from that you can find examples of the 256-character
hex strings denoted above by "hxs-mask," which seem
to specify a type code for each possible character byte.
Mika Heiskanen's "Everything in ROM" (as of HP48)
http://www.hpcalc.org/details.php?id=1782
http://www.hpcalc.org/hp48/programming/entries/ent_srt.zip
Nosy the ribiter, by Jurjen N.E. Bos
http://www.hpcalc.org/details.php?id=4323
http://www.hpcalc.org/hp49/programming/misc/nosy.zip
My own first tokenizer:
http://en.wikipedia.org/wiki/Image:Nyc_transit_authority_token.png
And its relatives:
http://images.nycsubway.org/logo/sit150.gif
http://www.nycsubway.org/tech/tokens/
http://www.nycsubway.org/tech/tokens/tokensmedals.html
Cheap imitations:
http://www.nycsubway.org/perl/show?47686
[r->] [OFF]
Ciao Massimo.
Just a hint more - I found extremely helpful to read some of the
original patents about direct and indirect execution of object types
(for example) that were gathered by Eric Smith on its website:
http://www.brouhaha.com/~eric/hpcalc/patents/
In particular, I went through the "Data processing system and method
for the direct and indirect execution of uniformly structured object
types" (http://www.brouhaha.com/~eric/hpcalc/patents/4868745.pdf)
Of course, please consider that the document was not written with
"information dissemination" as the first goal (i.e.: it's not
structured as an article, but - guess what? - as a strictly technical
and "bureaucratic" document).
However, it can give some helpful insights over the concept and
operation of some basic structures (e.g.: the inner loop).
Hope this helps.
Saluti.
Giancarlo
If you want to decompose a string on to the stack, use SysRPL command
INNERCOMP (#54AFh SYSEVAL) followed by UNCOERCE (#18DBFh SYSEVAL)
Matt
> If you want to decompose a string on to the stack,
> use SysRPL command INNERCOMP followed by UNCOERCE
INNERCOMP breaks up composites (Lists, Programs,
Algebraic and Unit objects) into separate components;
since when (and how) has it been made useful with strings?
On the HP48 series, it will make a mess with a string arg;
with the current HP49 ROM, it manages to leave
"A B C" alone, returning a count of #1 (system binary);
I don't know whether it's harmless, however.
I also don't see where one supplies
the necessary additional info for tokenizing
(i.e. breaking at what characters?)
[r->] [OFF]
> UNCOERCE (#18DBFh SYSEVAL)
That was an HP48 series address (not for HP49)
It's a bit dangerous to use wrong addresses,
and/or to use internal functions
with wrong argument types.
"Don't do this at home"
[r->] [OFF]
> MAWK is a great library for string manipulation:
But I want to build a program/lib self contained without reference to
external libs.
I take note for future programs.
MS
> In particular, I went through the "Data processing system and method
> for the direct and indirect execution of uniformly structured object
> types" (http://www.brouhaha.com/~eric/hpcalc/patents/4868745.pdf)
Good reading for these days with very cold nights! ;-)
Thanks for signaling it.
MS
GetNextToken ( hxs-mask $ #start --> hxs-mask $ #next $token )
getmatchtok ( hxs-mask $ #loc $_tok --> hxs-mask $ #next $match )
Using Nosy, you can find where these are called within ROM,
and from that you can find examples of the 256-character
hex strings denoted above by "hxs-mask," which seem
to specify a type code for each possible character byte.
A very hard way!
MS
>> GetNextToken ( hxs-mask $ #start --> hxs-mask $ #next $token )
>> getmatchtok ( hxs-mask $ #loc $_tok --> hxs-mask $ #next $match )
> A very hard way!
Isn't it a built-in near-analog of "strtok"?
http://www.cplusplus.com/reference/clibrary/cstring/strtok.html
Then it should be the very easiest way (no additional programming,
fastest possible results); only the research to find out
what the "hxs-mask" codes mean may be "hard," but once you do,
you can make a table for posterity, and save yourself
the need for coding your own function(s).
[r->] [OFF]
> Isn't it a built-in near-analog of "strtok"?
Very similar.
For me using something not documented is not good... but It seems normal in
this world!
Why HP not documented all the APIs?
MS
There is no protection on HP48 series,
but I just read remarks said to be by JYA in post from Sep 8 2000
http://groups.google.com/group/comp.sys.hp48/msg/3ad9ac3dd0eabb82
> Actually, INNERCOMP has been patched on the HP49
> to never generate an invalid object or to corrupt memory.
> On the HP48, INNERCOMP can be run only on a composite object
> [ONLY: program, list, algebraic, unit object]
> While on the HP49, if you run it on something else than
> a composite object, it will return the same object and ONE.
Yep, the second line within INNERCOMP,
formerly GOSUBL SAVPTR, has been replaced by
another GOSUBL, to a location which begins with
GOSUBVL SAVPTR, and then apparently performs
a test for composite object (using some "black magic"?)
I wonder why this nice favor was done (costing slight overhead),
and whether any programs (or ROM functions) now *depend* on this?
At any rate, it's useless for strings on the 49 series,
and still dangerous on the 48 series.
[r->] [OFF]