Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STRTONUM MATCH FUNCTION QUESTION ... 1

Status
Not open for further replies.

teletubby5e

Technical User
Oct 31, 2002
147
US
Hey folks,
I am sure that I am missing something here, but basically, am trying to input the starting and ending numbers of a range of numbers to build in a switch, have the script convert these strings to base 10 numbers in order to do a for x = y upto z counter. then convert that number back to a string back to a string to build the lines, then increment one, and start all over. but my script is failing the integer math part. please help.
here is the basic script, some repetitive functions are removed:

PROC MAIN
STRING STARTNUM
STRING ENDNUM
STRING NUMBER_STR
STRING DIDNUMADD

STRING STATUS
STRING MODE
STRING MODE2

INTEGER STARTNUM_NUM
INTEGER ENDNUM_NUM
INTEGER NUMBER_NUM

SDLGINPUT "ENTER" "FIRST NUMBER OF RANGE (i.e. 2145551212):" STARTNUM
SDLGINPUT "ENTER" "LAST NUMBER OF RANGE (i.e. 2145559999):" ENDNUM
STRTONUM STARTNUM STARTNUM_NUM 10 ; CONVERTS STRING TO A BASE 10 NUMBER TO PERFORM MATH
STRTONUM ENDNUM ENDNUM_NUM 10 ; CONVERTS STRING TO A BASE 10 NUMBER TO PERFORM MATH

SDLGINPUT "ENTER" "NEW DIDs, OR CHG EXISTING, OR OUT? (NEW/CHG/OUT):" STATUS

STRFMT MODE2 "%s!" STATUS

FOR NUMBER_NUM=STARTNUM_NUM UPTO ENDNUM_NUM ; 2145551212 UPTO 2145559999 FOR LOOP

NUMTOSTR STARTNUM_NUM STARTNUM 10 ; CONVERTS FIRST NUMBER TO A STRING
NUMTOSTR ENDNUM_NUM ENDNUM 10 ; CONVERTS LAST NUMBER TO A STRING
NUMTOSTR NUMBER_NUM NUMBER_STR 10 ; CHANGES TOTAL FROM A NUNMBER TO A STRING

STRFMT DIDNUMADD "TN=%.10s!" STARTNUM
STRFMT MODE "FORM=1V5&%s!" STATUS

TRANSMIT MODE
WAITFOR ": " FOREVER
TRANSMIT DIDNUMADD
WAITFOR ": " FOREVER
TRANSMIT MODE2
WAITFOR ": " FOREVER

STARTNUM_NUM=STARTNUM_NUM++ ; ADD 1 TO VALUE OF 2145551212 BEFORE NEXT LOOP

ENDFOR

TRANSMIT "END;"
ENDPROC

many thanks. jeff
 
Jeff,

Replace the 10 with a 2 for a Base 10 Number.

Hank camphm@bellsouth.net
 
Jeff,

I checked and you'll need to use the ATOI Command to do what you want to do. Example:

String sNumber = "5551212"
Integer Digits

Atoi sNumber Digits

Digits++


Hank
camphm@bellsouth.net
 
THANKS HANK. WORKED LIKE A CHARM. NOW I AM JUST WORKING WITH THE ATOL FUNCTION AS APPARENTLY IF I TRY TO INSERT THET ENTIRE TELEPHONE NUMBER AREA CODE AND ALL, IT FLIPS OUT PROCOMM, SO NOW I JUST HAVE TO HARD CODE THE AREA CODE IN THE SCRIPT, OR PERHAPS PROMPT FOR IT WITH A FLGBOX. THANKS AGAIN! JEFF

PROC MAIN

STRING STARTNUM
STRING ENDNUM

INTEGER NUM1
INTEGER NUM2

ERRORLOOP:
SDLGINPUT "ENTER" "STARTING NUMBER (NO AREA CODE i.e.6981000)" STARTNUM
SDLGINPUT "ENTER" "ENDING NUMBER (i.e.6981099)" ENDNUM

ATOI STARTNUM NUM1 ; CONVERT TO INTEGER
ATOI ENDNUM NUM2

MAINLOOP:
;============== BEGIN NUMBER INSERTION SUBROUTINE HERE==
USERMSG "THIS IS JUST A DEMO OF THE ATOI FUNCTION"
STATMSG "BUILDING LINE (318) %s UPTO (318) %s " STARTNUM ENDNUM
MSPAUSE 250 ; PAUSES A QRTR OF A SEC
;===END NUMBER INSERTION SUBROUTINE HERE ===============

ATOI STARTNUM NUM1 ; CONVERT TO INTEGER
ATOI ENDNUM NUM2

IF NUM2<NUM1
USERMSG &quot;FIRST NUMBER MUST BE LESS THAN ENDING NUMBER&quot;
GOTO ERRORLOOP
ELSE
ENDIF

NUM1++ ; ADDS 1

ITOA NUM1 STARTNUM ; CONVERT TO STRING
ITOA NUM2 ENDNUM

IF NUM1==NUM2+1 ; CK TO SEE IF COMPLETE
USERMSG &quot;COMPLETED&quot;
HALT
ELSE
GOTO MAINLOOP
ENDIF

ENDPROC
 
Jeff,

The &quot;Flip Out&quot; occurs because a 10 Digit Phone Number exceeds the 32 Bit range. (4 x 10 = 40). But you can split the 10 digit phone number and increment just the 7 digits without the area code. See below.. Maybe it will give you some ideas.

Hank

Proc Main
string num = &quot;8005551212&quot;
string ac, phone
integer snew
string tele
substr ac num 0 3
substr phone num 3 7
atoi phone snew
snew++
strfmt tele &quot;%s%d&quot; ac snew
Usermsg &quot;%s&quot; tele
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top