From: Jan Brittenson <bson@rice-chex.ai.mit.edu>
Subject:  v03i001:  ncat - Utilities: NCAT, NCATLF, and NREV v1.0, Part01/01
Newsgroups: comp.sources.hp48
Keywords: utilities ncat ncatlf nrev
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu

Checksum:  452246370 (verify with brik -cv)
Submitted-by: Jan Brittenson <bson@rice-chex.ai.mit.edu>
Posting-number: Volume 3, Issue 1
Archive-name: ncat/part01


This posting and all code included in it is public domain.

   This posting presents three commands: NCAT, NCATLF, and NREV. At
the end is the source code in STAR assembler in the form of a tar
archive, so you can adopt the commands for use in libraries, or make
other customizations. The commands included are:


	NCAT

	Concatenate N strings

		stringN ... string2 string1 N
			-->
		string1+string2+...stringN



	NCATLF

	Concatenate N strings, but automatically add a linefeed to
	each string. Useful for creating printouts and displays.

		stringN ... string2 string1 N
			-->
		string1+LF+string2+LF+...stringN+LF



	NREV

	Reverse order of N objects on the stack. Notice that N is
	left in level 1.

		itemN ... item1 item2 N
			-->
		item2 item1 ... itemN N



   NCATLF is convenient for generating strings to be displayed using
DISP. A linefeed will cause the remained of the string to be displayed
on the next line. For instance,

	"line1" "line2" "line3" 3 NCATLF 1 DISP

will result in the equivalent of:

	"line3" 1 DISP
	"line2" 2 DISP
	"line1" 3 DISP

   There is no significant difference in speed (the former method is
approximately 5% faster) between the two examples above. However,
using NCATLF is be more convenient than using a loop to disp an
arbitrary number of lines.

   Notice the reverse order of the output. This is easily corrected
using NREV. Don't worry about speed; NREV will reverse 1000 objects
0.6 seconds. The following example does what one might expect:

	{ "line 1" "line 2" "line 3" } OBJ-> NREV NCATLF 1 DISP



						-- Jan Brittenson
						   bson@ai.mit.edu

