× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hans,

I am trying to make this sort of dynamic :)  I am trying the following:

D size            S              5P 0
 *
 * Load the DS
 *
C                   Eval      size = %Size(Structure)* 3
C                   Eval      StructurePoint = %Alloc(size)

The number 3 will be softcoded in the program, but I am getting a numeric
error when allocating the size.  (The error is The target for a numeric
operation is too small to hold the result).  I don't understand why I am
getting the error.  If I hard code the size as the number 60, there are no
problems and everything works well.

Mike


----- Original Message -----
From: "Hans Boldt" <boldt@ca.ibm.com>
To: <rpg400-l@midrange.com>
Sent: Tuesday, September 03, 2002 10:57 AM
Subject: Re: Multiple occurrence Data Structure


> Mike Silvers wrote:
> > I am trying to have a multiple occurrence data structure and manipulate
it
> > using pointers.  I am having a problem.  I am always getting the last
data I
> > have entered.  Here is the sample program:
> >
> > D Structure       DS
> > D    Struct_F1                  20
> >  *
> > D StructurePoint...
> > D                 S               *
> > D SPH             S               *
> >  *
> > D TestData        S             20A
> >  *
> >  * Load the DS
> >  *
> > C                   Eval      SPH = %Addr(Structure)
> > C                   Eval      StructurePoint = %Addr(Structure)
> > C                   Eval      Struct_F1 = 'Position #1'
> > C                   Eval      StructurePoint =
> > C                                StructurePoint + %Size(Structure)
> > C                   Eval      Struct_F1 = 'Position #2'
> > C                   Eval      StructurePoint =
> > C                                StructurePoint + %Size(Structure)
> > C                   Eval      Struct_F1 = 'Position #3'
> >  *
> >  * Loop through the DS
> >  *
> > C                   Eval      StructurePoint = SPH
> > C                   Eval      TestData = Struct_F1
> > C                   Eval      StructurePoint =
> > C                                StructurePoint + %Size(Structure)
> > C                   Eval      TestData = Struct_F1
> > C                   Eval      StructurePoint =
> > C                                StructurePoint + %Size(Structure)
> > C                   Eval      TestData = Struct_F1
> >  *
> > C                   Return
> >
> > any ideas in where I am going wrong?
> >
> > what I am trying to accomplish is a have an unlimited number of data
> > structure's sent to the program and in the program I loop through the
data
> > structures and process the information.  The parms passed will be the
> > pointer to the data structure and the number of occurrences.
>
> Try coding something like:
>
> ----------------------------------------------------------------
> D Structure       DS                 BASED(StructurePoint)
> D    Struct_F1                  20
>   *
> D StructurePoint...
> D                 S               *
> D SPH             S               *
>   *
> D TestData        S             20A
>   *
>   * Load the DS
>   *
> C                   EVAL      StructurePoint = %ALLOC(SIZE)
> C                   EVAL      SPH = Structure
> C                   Eval      Struct_F1 = 'Position #1'
> C                   Eval      StructurePoint =
> C                                StructurePoint + %Size(Structure)
> C                   Eval      Struct_F1 = 'Position #2'
> C                   Eval      StructurePoint =
> C                                StructurePoint + %Size(Structure)
> C                   Eval      Struct_F1 = 'Position #3'
>   *
>   * Loop through the DS
>   *
> C                   Eval      StructurePoint = SPH
> C                   Eval      TestData = Struct_F1
> C                   Eval      StructurePoint =
> C                                StructurePoint + %Size(Structure)
> C                   Eval      TestData = Struct_F1
> C                   Eval      StructurePoint =
> C                                StructurePoint + %Size(Structure)
> C                   Eval      TestData = Struct_F1
>   *
> C                   Return
> --------------------------------------------------------------------
>
> That is, you need to define your DS as based, and you need to
> allcoate storage for the DS somehow.
>
> Cheers!  Hans
>
>
>
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
> or email: RPG400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>
>




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.