Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

why not possible to use array variable as operand

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: why not possible to use array variable as operand
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: 3158
Location: Tucson AZ

PostPosted: Mon Jan 22, 2007 2:43 pm    Post subject:
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

Site Director


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

PostPosted: Mon Jan 22, 2007 7:25 pm    Post subject:
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    Post subject: hi i read this statement from ref book
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: 3158
Location: Tucson AZ

PostPosted: Tue Jan 23, 2007 3:47 pm    Post subject:
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

Site Director


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

PostPosted: Tue Jan 23, 2007 7:04 pm    Post subject:
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    Post subject: array
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: 3158
Location: Tucson AZ

PostPosted: Wed Jan 24, 2007 3:42 pm    Post subject: Re: array
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    Post subject: array
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: 3158
Location: Tucson AZ

PostPosted: Wed Jan 24, 2007 5:35 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Wed Jan 24, 2007 6:36 pm    Post subject:
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    Post subject: thnaks
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    Post subject: Re: why not possible to use array variable as operand
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 26, 2007 8:45 pm    Post subject:
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    Post subject: Re: why not possible to use array variable as operand
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 26, 2007 10:49 pm    Post subject:
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    Post subject: Re: why not possible to use array variable as operand
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us