• Re: HELD

    From mhx@21:1/5 to dxf on Thu Apr 25 06:35:48 2024
    dxf wrote:

    This is a new word introduced by MPE. It avoids some of the complications when
    using #> to return the current contents of the PNO buffer. The definition is:

    HELD ( -- caddr len )

    Return the address and length of the string held in the pictured numeric output
    buffer.

    HELD is a factor of #> allowing the latter to be defined:

    : #> 2DROP HELD ;

    So if you've found yourself writing 0 0 #> or <# 2DUP HOLDS #> to avoid the
    2DROP built into #> then HELD may be a neater solution.

    Doesn't everybody use the low level factors of "." etc.? Wanting to format
    a number in a special way is rather infrequent, but not wanting to print a number right away is common.

    25 (.) TYPE
    PI (F.) TYPE

    -marcel

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to dxf on Thu Apr 25 10:51:40 2024
    dxf wrote:

    [..]
    (F.) is an example of where I used HELD two or three times. Some others:

    \ Return string right-aligned as a2 u2. Uses HOLD buffer
    : RJUST ( a u +n c -- a2 u2 )
    >r >r <# shold held r> over - 0 max r> nhold #> ;
    [..]
    HOLDS (200x) recognizes that the numeric conversion buffer can and is used for
    string processing. In that situation HELD is often more appropriate than #> .

    I was never really satisfied with this low-level assembly work.
    Nowadays I use device redirection to a string, for example:

    : dd>matlab ( F: sel -- ) ( -col -- c-addr u )
    FLOCAL sel
    LOCAL -col
    |resudata 0= IF S" >matlab :: ERROR :: TASK-DATA is unavailable." EXIT ENDIF <$$ ." %% iSPICE output" CR ." % "
    #|params 0 ?DO I -col <> IF |head .pnames I CSTR[] .$ .FOURTABS
    ENDIF
    LOOP
    #|results 0 ?DO I >headrow .resname .$ .FOURTABS LOOP
    CR ." data = ["
    #|tasks
    0 ?DO -col 0> IF |head .paramdata I #|params * -col +
    DFLOAT[] DF@ sel -1e-4 F~ ( equal to 0.01% )
    ELSE TRUE
    ENDIF
    IF CR #|params 0 ?DO I -col
    <> IF |head .paramdata
    J #|params * I +
    DFLOAT[] DF@ +E. 3 SPACES
    ENDIF
    LOOP
    #|results 0 ?DO |resudata J #|results * I +
    DFLOAT[] DF@ +E. 3 SPACES
    LOOP
    ENDIF
    LOOP
    CR ." ];"
    CR
    ;

    : .JOB>console ( -- ) 0e -1 dd>matlab TYPE ;
    : .JOB>matlab ( -- ) 0e -1 dd>matlab MFILE-NAME DUMP-TO-FILE ;

    -marcel

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