Topic: Limiting characters in text register (1 of 6), Read 32 times
Conf: Basic editing, Block operations
From: Les Hazlett
Date: Tuesday, June 22, 2004 01:24 PM

I need to insert a 3 digit number (with leading zeros) into a text file - at the cursor. The number is in a numeric register and has a range of 1-999. I can put this number into a text register using Num_Str with the FILL option to get the leading zeros. However, I get a 5 digit number and I want it to be only 3. Is there some easy way to limit the number of characters in the text register so that I can simply use Reg_Ins to put it into the text file? Thanks for your help.

 


Topic: Re: Limiting characters in text register (2 of 6), Read 31 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Tuesday, June 22, 2004 04:11 PM

On Tue, 22 Jun 2004 13:24:00 -0400, Les Hazlett wrote:

>I need to insert a 3 digit number (with leading zeros) into a text file - at
>the cursor. The number is in a numeric register and has a range of 1-999. I
>can put this number into a text register using Num_Str with the FILL option to
>get the leading zeros. However, I get a 5 digit number and I want it to be
>only 3. Is there some easy way to limit the number of characters in the text
>register so that I can simply use Reg_Ins to put it into the text file?

You can try it this way (without checking the number's range):

#103=56 // the number is in Num-Reg 103
Num_Str(#103, 103, FILL) // fill it into T-Reg with leading zeros
Reg_Ins(103, BEGIN) // insert T-Reg 103 at cursor with 5 digits
Del_Char(2) // delete the first two digits
Char(3) // advance past inserted number


Christian

 


Topic: Re: Limiting characters in text register (5 of 6), Read 29 times
Conf: Basic editing, Block operations
From: Les Hazlett
Date: Thursday, June 24, 2004 08:31 AM

Thank you for your help. I still don't know how to use this board. I sent a thank you before and it never posted. Hum????

 


Topic: Re: Limiting characters in text register (3 of 6), Read 41 times
Conf: Basic editing, Block operations
From: Ted Green
Date: Tuesday, June 22, 2004 06:34 PM

At 01:24 PM 6/22/2004, you wrote:
>From: "Les Hazlett"
>
>I need to insert a 3 digit number (with leading zeros) into a text file - at the cursor. The number is in a numeric register and has a range of 1-999. I can put this number into a text register using Num_Str with the FILL option to get the leading zeros. However, I get a 5 digit number and I want it to be only 3. Is there some easy way to limit the number of characters in the text register so that I can simply use Reg_Ins to put it into the text file? Thanks for your help.

First of all, you can insert numbers directly into the file using the Num_Ins() command; you don't need to use Num_Str() and Reg_Ins().

Num_Ins() and Num_Str() are both based on Num_Type() and have exactly the same options.

These commands have some additional options which I haven't documented yet, but which do exactly what you want. Here is some sample code:

#1 = 99 //Numeric register 1 contains the number

Num_Ins(#1,SIMPLE+FILL+COUNT,3) //Insert #1 as an unsigned number in a
//field of 3 characters with leading zero

Note that you must use the "SIMPLE" option to specify this is an unsigned number; otherwise the first column is reserved for the sign.

-----------------------------------
Here is our internal doco on these commands with all options:

;
; Num_Ins(n) - Insert ASCII of 'n' into edit buffer. (ARG_NO)
; OPTIONS - same as for Num_Type()
;
; Num_Str(n,r) - Place ASCII of 'n' into T-Reg 'r'. (ARG_2N)
; Num_Str(n,r,APPEND) - Append ASCII of 'n' to end of T-Reg 'r'.
; Num_Str(n,r,INSERT) - insert ASCII of 'n' at beginning of T-Reg 'r'.
; Other OPTIONS - same as for Num_Type().
;
; Num_Type(n) - Type value of 'n'. (ARG_NO)
; Num_Type(n,LEFT) - Type left justified.
; Num_Type(n,NOCR) - Type without following newline.
; Num_Type(n,HEX) - Display in hex (always left justified).
; NT( n,HEX+NOMSG) - Suppress "0x" and ":"
; Num_Type(n,FILL) - Pad with "0" instead of spaces.
; Num_Type(n,FORCE)- Always display 10 columns.
; Num_Type(n,EXTRA)- Display extra padding if positive number.
;
; Following options are new, improved and different.
; When COUNT is used, no CRLF automatically issued.
; Can also be combined with the following:
;
; O_COUNT - required: LSB = field width;
; middle 2 bytes reserved for floating point;
; upper byte: optional error char ('*' override).
; O_APPEND - display sign at end of number.
; O_FILL - pad with "0" instead of spaces.
; Note: currently same as REVERSE.
; O_FORCE - display '+' instead of ' ' for positive numbers.
; O_SIMPLE - treat as unsigned (%u, in "c").
; O_HEX - display in hex (always unsigned).
; O_FLOAT - 'n' is id of numreg with IBM 360 style floating
; point number: #n=0xh3h2h1SX, where:
; h1 = most significant hex digit;
; S is the sign bit;
; X is the exponent biased on 64. (Powers of
; 16). Typically 0x4n (pos) and 0xCn (neg).
; O_EXTRA - IBM-style double precision floating point number.
; Combined with O_FLOAT; redefines old-style usage.
; numreg[n] and numreg[n+1] are double precision:
; #n=0xh3h2h1SX; #n+1= 0xh7h6h5h4.
; O_EVAL - Evaluate from *EDTPTR ('n' is dummy). Currently
; with O_FLOAT only.
; O_SUPPRESS - suppress padding (with O_LEFT only).
;
; Note: do not use "NOCR" with COUNT; no CRLF is issued anyway and NOCR
; is the same as SUPPRESS which is already being used.
;

Yes, these commands can convert from floating point numbers to ASCII, but I'm not ready to document it now.

Ted.

 


Topic: Re: Limiting characters in text register (4 of 6), Read 46 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Wednesday, June 23, 2004 02:11 AM

On 6/22/2004 6:34:46 PM, Ted Green wrote:
>[Num_Ins]
>These commands have some additional options which I
>haven't documented yet, but which do exactly what you
>want.

All I can say: GREAT!!!

Christian

 


Topic: Re: Limiting characters in text register (6 of 6), Read 39 times
Conf: Basic editing, Block operations
From: Les Hazlett
Date: Thursday, June 24, 2004 08:32 AM

Ted,
That's great. Thanks for the new information.
Les