STRINGv1.0 -- String manipulation commands.


Contents.
===============================================================================================


This library contains 8 commands:

 1.- int->str: Converts the integer part of a number into a string.

 2.- StrPadL:  Pads a string with whitespace, left-justified.

 3.- StrPadR:  Pads a string with whitespace, right-justified.

 4.- S->L:     Converts a string to a list of substrings by separating at a given character.

 5.- S->L1:    Same as above, but treats consecutive separators as one.

 6.- SEP$AT:   Separates a string at the first point it finds a given character.

 7.- isOb:     Tries to convert a string to an object of the specified type.

 8.- ABOUT:    Displays information about this library.



Change History.
===============================================================================================

No changes yet.



Usage.
===============================================================================================


  1.- int->str

When one wants to display integers (for example, an index count), int->str can be used instead
of ->STR, which is dependent on flag settings such as FIX mode, or DEC, HEX, BIN, OCT.

Arguments:
1: x                 @ real number of user binary

Results:
1: "i"               @ integer part of x, as string

Examples:
1: 1.000     ->      1: "1"

1: #1Ah      ->      1: "26"


-----------------------------------------------------------------------------------------------


  2.- StrPadL

I use this command when I'm creating tabulated text, or fixed-length format files. If the
string exceeds the length given, it is truncated and an ellipsis (Chr_31: ...) is appended.

Arguments:
2: ob                @ original object, if not a string does ->STR
1: l                 @ length of result

Results:
1: "ob"              @ string of length 'l' representing 'ob'

Examples:
2: "Hello"
1: 10        ->      1: "Hello     "

2: 1.252
1: 10        ->      1: "1.252     "


-----------------------------------------------------------------------------------------------


  3.- StrPadR

Same as above, only that right-justified.

Arguments:
2: ob                @ original object, if not a string does ->STR
1: l                 @ length of result

Results:
1: "ob"              @ string of length 'l' representing 'ob'

Examples:
2: "Hello"
1: 10        ->      1: "     Hello"

2: 1.252
1: 10        ->      1: "     1.252"


-----------------------------------------------------------------------------------------------


  4.- S->L

Can be used, for example, to break a text at newlines, collecting each line as a separate
string.

Arguments:
2: "string"          @ original string
1: "sep"             @ separator (only the first char is used)

Results:
1: { "s1" "s2"
    ... "sn" }       @ collection of substrings

Examples:
2: "First
    Second   ->      1: { "First"
    Third"                "Second"
1: "\n"                   "Third" }

NOTE: "\n" represents the newline character.


-----------------------------------------------------------------------------------------------


  5.- S->L1

Same as above, but treats consecutive separators as one.

Arguments:
2: "string"          @ original string
1: "sep"             @ separator (only the first char is used)

Results:
1: { "s1" "s2"
    ... "sn" }       @ collection of substrings

Examples:
2: "1 2  3 4   5"
1: " "       ->      1: { "1" "2" "3" "4" "5" }


-----------------------------------------------------------------------------------------------


  6.- SEP$AT

This routine is called by S->L and S->L1. It splits a string at a given character.

Arguments:
2: "string"          @ original string
1: "sep"             @ separator (only the first char is used)

Results:
2: "s1"              @ string up to "sep", exclusive.
1: "s2"              @ rest of string, excluding "sep".

Examples:
2: "Diego Berge"     2: "Diego"
1: " "       ->      1: "Berge"

2: "D B S"           2: "D"
1: " "       ->      1: "B S"


-----------------------------------------------------------------------------------------------


  7.- isOb

Tries to convert a string to an object of a specific type, returns the object on success, or
leaves the string untouched otherwise. Object type numbers are the same as for the TYPE command.

Arguments:
2: "string"          @ string
1: type              @ object type number

Results (on success):
1: ob                @ object

Results (on failure):
1: "string"

Examples:
2: "3.52"
1: 0         ->      1: 3.52

2: "Text"
1: 0         ->      1: "Text"

2: "(32 9)"
1: 1         ->      1: (32,9)


---

Checksum: # 46220d
Bytes:      713.0

Provided AS IS. Use at your own risk.

Comments to: <dberge@mx2.redestb.es> / <dberge@geocities.com>

(c)1999 Diego Berge
1999-05-27 16:24 UTC
