IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

why not possible to use array variable as operand


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Mon Jan 22, 2007 11:05 am
Reply with quote

Hi all friend,
i want to know why we cant use array variable as varible in operation like +, _ etc
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jan 22, 2007 2:43 pm
Reply with quote

Why do you say we can't? Can you give an example?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jan 22, 2007 7:25 pm
Reply with quote

Hello,

Array variables are often used in comnputations. Make sure that you have properly defined them.

If you post your code and your error message (if you got one), we will be able to help. If youi got undesired results, please post that also.
Back to top
View user's profile Send private message
devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Tue Jan 23, 2007 9:47 am
Reply with quote

William Thompson wrote:
Why do you say we can't? Can you give an example?
'

declare array_A(10) float binary;
declare array_B(10)fixed binary static
initial (0,l,2,3,4,5,6,7,8,9);
declare i fixed binary;
do i = 1 to 10;
array_A(i) = sqrt(array_B(i));
end;

variables cannot be operands for arithmetic operators such as
+ and ? . For example, any statement of the form:

C= A + B;
is invalid if A, B, and C are array variables.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jan 23, 2007 3:47 pm
Reply with quote

PL/I? I don't know. Assembler and COBOL I do. There they can without restriction.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jan 23, 2007 7:04 pm
Reply with quote

Hello,

Please post the actual error message.
Back to top
View user's profile Send private message
devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Wed Jan 24, 2007 3:21 pm
Reply with quote

Hi all,
i not tried it practically but while reading the book i got..
i know we can use array variable in calculation using subscipt or index e why not without index or subscipt.......
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 24, 2007 3:42 pm
Reply with quote

devidas-patil wrote:
i not tried it practically but while reading the book i got..
Can you quote the part of the book that gives you this idea?
Quote:
i know we can use array variable in calculation using subscipt or index e why not without index or subscipt.......
Without the subscript or index, which member of the array would be used?
Back to top
View user's profile Send private message
devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Wed Jan 24, 2007 5:28 pm
Reply with quote

i know without subscript we cant but i want to know that only why...thats was my basic question?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 24, 2007 5:35 pm
Reply with quote

Why? Because "without the subscript or index, which member of the array would be used?"
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Wed Jan 24, 2007 6:36 pm
Reply with quote

In addition to Bill:

So it's just about subscripting icon_cry.gif Suppose you're in a street with 10 sidestreets. You want to reach some address and ask me the way. What would it bring you if I told you to go strait ahead and then turn left? You'd ask me which sidestreet to turn into; well that's exactly what the computer would need to know.
Back to top
View user's profile Send private message
devidas-patil

New User


Joined: 08 Jan 2007
Posts: 54
Location: pune

PostPosted: Mon Feb 19, 2007 11:50 am
Reply with quote

Thnaks
i was on leave so not replied..
hanks for your co-operation..
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Mon Mar 26, 2007 8:37 pm
Reply with quote

HI,
It is possible to use array name as variable in expressions like
i) C = A + B ;
ii)C = A * 5 ;
iii) C = A * B (i ) ;
Where A,B and C are arrays..

But there are some restrictions..for example in i) statement

A,B and C should be declared with the same bounds and substript ranges..

Regards,
Raj
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 26, 2007 8:45 pm
Reply with quote

Would you give an example of how you would define A, B and C as arrays?
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Mon Mar 26, 2007 9:02 pm
Reply with quote

Hello Thompson,
You can declare the array variables as follows...

DCL (A(5),B(5),C(5)) FIXED BIN(31,0);
here all array sizes are equal and default bounds are considered from 1 to 5.

If you want to specify your own bounds then bounds of all arrays should match...
eg:
DCL (A(3:7),B(3:7),C(3:7)) FIXED BIN (31,0);

Regards,
Raj
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 26, 2007 10:49 pm
Reply with quote

Oh dear, that weird language......But you have answered as I expected you would....
You want the compiler to be smart enough to do something like a "corresponding" function - C = A B would go as C(n) = A(n) B(n) where n = 1 through the max size of the array, right?
I don't think that is allowed but it would be very easy to write a small generalized routine to do it.
Back to top
View user's profile Send private message
cheryala

New User


Joined: 20 Mar 2006
Posts: 46

PostPosted: Mon Apr 02, 2007 6:08 pm
Reply with quote

Yes thomson, What you said is correct. It performs exactly what you said.

Regards,
Raj
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top