Re: [U2] To DIM a passed Matrix or not ?

2006-03-08 Thread Ray Wurlod
It IS necessary to DIM it in the called routine, not to establish its size 
(extent) but to establish the number of dimensions (1 or 2).  In your example, 
DIM matrix(1) would have been sufficient.  But DIM matrix(50,2) would cause a 
run-time error.

 - Original Message -
 From: Jacques G. [EMAIL PROTECTED]
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] To DIM a passed Matrix or not ?
 Date: Tue, 7 Mar 2006 06:35:59 -0800 (PST)
 
 
  In Universe, it isn't necessary to DIM a matrix that
 has been passed in a subroutine.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] To DIM a passed Matrix or not ?

2006-03-07 Thread TPellitieri
Jacques G. [EMAIL PROTECTED] wrote on Mon, 6 Mar 2006 07:51:51 -0800
(PST):

 In Universe, it isn't necessary to DIM a matrix that
 has been passed in a subroutine.  So my question is,
 are there MV flavors where it is neccessary to do so ?

We use UniData with Pick flavor (under SB+).  I tried this test program:

SUBROUTINE MAT.TEST(MAT PARM)
FOR I = 1 TO 100
   PRINT PARM(I):, :
   IF NOT(MOD(I,10)) THEN PRINT
NEXT I
PRINT Done!
RETURN

When I tried to compile it, I got these errors:

Compiling Unibasic: BP/MAT.TEST in mode 'p'.
warning: PARM may be one dimension matrix.
redefined variable PARM near line 3
matrix PARM undefined.
compilation failed

I had to add the DIM PARM(100) statement to get this to compile.

Please note that the CALLING program determines the size of the array, not
the subroutine.  With the example above corrected, I tried the following
program:

DIM CHK(50)
FOR I = 1 TO 50
   CHK(I) = I * I
NEXT I
CALL MAT.TEST(MAT CHK)
STOP

When I ran the program, it bombed out when I=51, since CHK was only
dimensioned to 50.

Suggestion with this syntax:  include the size of the array as a parameter.
My corrected versions of these programs follow:

DIM CHK(50)
FOR I = 1 TO 50
   CHK(I) = I * I
NEXT I
CALL MAT.TEST(MAT CHK,50)
STOP

SUBROUTINE MAT.TEST(MAT PARM, SIZE)
DIM PARM(SIZE)
FOR I = 1 TO SIZE
   PRINT PARM(I):, :
   IF NOT(MOD(I,10)) THEN PRINT
NEXT I
PRINT Done!
RETURN

--Tom Pellitieri
  Century Equipment
  Toledo, Ohio

BE KIND!  DON'T OVERQUOTE!!
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] To DIM a passed Matrix or not ?

2006-03-07 Thread Jacques G.
In Universe, it isn't necessary to DIM a matrix that
has been passed in a subroutine. 

Just to clarify what I meant here.  The DIM or COM is
still done but it is done in the calling program.  It
isn't neccessary to dim it in the SUBROUTINE in
Universe.




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] To DIM a passed Matrix or not ?

2006-03-06 Thread Jacques G.
I've seen the following:

SUBROUTINE FOO(MAT FOOBAR)
   DIM FOOBAR(100)
   [... some code]
RETURN

In Universe, it isn't necessary to DIM a matrix that
has been passed in a subroutine.  So my question is,
are there MV flavors where it is neccessary to do so ?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/