• HP 48gx programming

    From mateosarzosa@gmail.com@21:1/5 to All on Thu Oct 18 23:14:53 2018
    Note:
    I don't know where this message is delivered.

    However, anyone reading this, please help me. I'd like to add this program to my HP48GX.
    It is for solving a system of linear equations. I plan to use it in my course of Electric Circuits (implies phasors and matrixes).

    If anyone there can help me checking this code, please explain me how to enter it on the calculator because I don't understand the syntax at all.


    The code is:
    %%HP: T(2)A(D)F(.);
    DIR
    ·\<-
    « VARS 1 OVER
    '·\<-' POS 1 - SUB
    PURGE
    »
    SYS
    « DUP SIZE \-> l
    n
    « n \->LIST
    'EQS' STO 0 n
    FOR i 1 n
    FOR j i j
    == 1 0 IFTE l j GET
    STO
    NEXT 1 n
    FOR j '
    EQS(j)' \->NUM
    NEXT n
    ARRY i
    IF NOT
    THEN NEG
    'VET' STO
    ELSE VET
    + ARRY\-> DROP
    END
    NEXT { n n
    } \->ARRY l PURGE TRN
    CONJ 'MAT' STO VET
    MAT / n 1
    FOR i DUP i
    GET \->Q l i GET STO
    -1
    STEP DROP
    MAT VET n 1 + COL+
    'MAT' STO 'VET'
    PURGE
    »
    »
    END

    Source and credits: http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv015.cgi?read=82010


    PS. I don't have the PC adapter for the calc, therefore I need to do it all manually.

    Thanks for investing time reading this.
    -Mateo

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From elturco@21:1/5 to All on Fri Oct 19 07:45:17 2018
    Start copying from DIR (DIR included), and pay attention to the spaces it should work.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Isaac Mateo Sarzosa Valencia@21:1/5 to All on Sat Oct 20 13:39:59 2018
    Thanks so much for replying.

    What does '\•<-' mean?

    Especially the upper-mid dot.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Hemphill@21:1/5 to Isaac Mateo Sarzosa Valencia on Sat Oct 20 17:22:35 2018
    Isaac Mateo Sarzosa Valencia <mateosarzosa@gmail.com> writes:

    Thanks so much for replying.

    What does '\•<-' mean?

    Especially the upper-mid dot.

    You don't have those characters in the correct order. It should be

    '•\<-'

    Whenever you encounter a backslash, it begins a three character code
    that describes a single HP48 character. \<- is the visible left arrow character. The single quotes surround a variable name, which in this
    case is comprised of a center dot and a left arrow. This is the name of
    a function, which is defined as part of the directory.

    Scott
    --
    Scott Hemphill hemphill@alumni.caltech.edu
    "This isn't flying. This is falling, with style." -- Buzz Lightyear

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Horrocks@21:1/5 to Scott Hemphill on Wed Oct 24 17:05:18 2018
    On 20/10/2018 22:22, Scott Hemphill wrote:
    Isaac Mateo Sarzosa Valencia <mateosarzosa@gmail.com> writes:

    Thanks so much for replying.

    What does '\•<-' mean?

    Especially the upper-mid dot.

    You don't have those characters in the correct order. It should be

    '•\<-'

    Whenever you encounter a backslash, it begins a three character code
    that describes a single HP48 character. \<- is the visible left arrow character. The single quotes surround a variable name, which in this
    case is comprised of a center dot and a left arrow. This is the name of
    a function, which is defined as part of the directory.

    The suggestion to start from the DIR and go to the END omitted to
    mention that this just gives you a directory object on the stack. You'll
    then need to to STO it - which will create a sub-directory.

    E.g.
    DIR A 33 END
    'ZZ' STO

    will create a sub-directory called ZZ in the current directory and it
    will contain a variable 'A' containing the value 33.

    Also, the HP Museum thread notes that the program as listed won't work
    on the 48G (because it uses the COL+ command) and an alternate version
    is supplied. I've incorporated that below.

    The program as listed is actually two, so it might be easier just to
    enter those one at a time and STO them individually.

    First program:

    « VARS 1 OVER '·\<-' POS 1 - SUB PURGE »
    '.\<-' STO

    (To enter '.\<-' I suggest pressing ' then CHARS then select char 183
    ECHO followed by char 142 ECHO)

    WARNING: DO NOT RUN THE .\<- PROGRAM AS IT WILL DELETE ALL YOUR
    VARIABLES INCLUDING THE FOLLOWING 'SYS' PROGRAM WHICH TAKES AN AGE TO
    ENTER ON THE CALCULATOR!!! Just delete the variables manually when you
    move to a new problem.

    Second program:

    «
    DUP SIZE \-> l n
    «
    n \->LIST 'EQS' STO
    0 n FOR i
    1 n FOR j
    i j == 1 0 IFTE
    l j GET STO
    NEXT
    1 n FOR j
    'EQS(j)' \->NUM
    NEXT
    n \->ARRY
    i IF NOT THEN
    NEG 'VET' STO
    ELSE
    VET + ARRY\-> DROP
    END
    NEXT
    { n n } \->ARRY
    l PURGE
    TRN CONJ 'MAT' STO
    VET MAT /
    n 1 FOR i
    DUP i GET l i GET STO
    -1 STEP
    VET ARRY\-> DROP {n 1} \->ARRY
    'VET' STO DROP
    »
    »

    'SYS' STO


    They aren't the best written programs in the world because (a) one uses
    PURGE (which is asking for trouble at the best of times) to remove all variables from the current directory (except itself) (except it doesn't)
    so use a separate directory (from your other work) to store both in
    otherwise you WILL lose work; and (b) the second creates variables which
    is not best practice - mostly because they're hard to clean up safely.

    The PURGE in the ./<- program simply doesn't work as intended. At the
    very least it needs to check for '.\<-' and 'SYS' and not purge those.

    Also the line "i j == 1 0 IFTE" could become "i j ==" since the IFTE is
    only returning true or false (1/0) which the == command does anyway.

    Hmm.

    --
    Bruce Horrocks
    Surrey
    England
    (bruce at scorecrow dot com)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)