From: David A Froble [davef@tsoft-inc.com] Sent: Tuesday, August 29, 2000 6:31 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: variable number of arguments (DEC Basic or Macro) IdrEASY wrote: > > Hi! > > I need to write function with variable number of arguments in DEC Basic, > maybe I could > do something with Macro (Alpha/VMS 7.x), but I'm not very familiar with > Macro. > > My colleges on work and we have some ideas with stack, but unfortunately > Basic have not > stack operations. > > Help, please. > > Thanks! What you are asking, in the manner you are asking, isn't possible in BASIC, and probably most/all other high level languages. You've gotten a number of posts giving some rather good methods to achieve your requirements, however, should you still need to use the capability you've asked for, then MACRO-32 can do this. I've included a simple routine that uses a variable number of arguments, what you're looking for is near the beginning, ignore the rest. ------------------------------------------------------ .TITLE CLRFLD - Clear string array headers used by DAS .IDENT "V1-01" ;++ ; ; Abstract: ; ; This routine will receive (n) arguments, the addresses ; of the array descriptors for string arrays. For each ; element in an array, (each string descriptor), the ; routine will set the length to zero, set the string ; type to dynamic, and set the address of the string to ; zero. This is the state of the descriptors when the ; program or subprogram that defined them is set-up. ; ; Author: ; ; Dave Froble ; ; Argument list: ; ; (AP) = Number of arguments ; 4(AP) = Address of string array descriptor 1 ; 8(AP) = Address of string array descriptor 2 ; . ; . ; ; Register usage: ; ; R2 - Number of arguments ; R3 - Array descriptor address ; R4 - Array element address ; R5 - Number of elements in array ; ;-- .PSECT $CODE,PIC,CON,REL,LCL,SHR,EXE,RD,NOWRT,LONG .CALL_ENTRY home_args=TRUE, max_args=32, label=CLRFLD ; ; Set up for number of arguments ; MOVL 0(AP),R2 ; Get number of arguments MOVZBL R2,R2 ; Zero fill high 3 bytes BLEQ 90$ ; Exit if no arguments MOVL #1,R6 ; ; Set up for an array ; 10$: MOVL (AP)[R6],R3 ; Array descriptor address MOVL 4(R3),R4 ; Address of first array element MOVL 20(R3),R5 ; Number of elements in array ; ; Loop thru array elements ; 20$: MOVB #2,3(R4) ; Set dynamic string flag MOVW #0,(R4)+ ; Set length to zero TSTW (R4)+ ; Skip to second longword MOVL #0,(R4)+ ; Set address to zero SOBGTR R5,20$ ; Do next array element ; INCL R6 SOBGTR R2,10$ ; Do next array ; ; Exit point ; 90$: RET ; Done, return .END ------------------------------------------------------ Dave -- David Froble Tel: 724-529-0450 Dave Froble Enterprises, Inc. Fax: 724-529-0596 DFE Ultralights, Inc. E-Mail: davef@tsoft-inc.com T-Soft, Inc. 170 Grimplin Road Vanderbilt, PA 15486