Re: Segfault using integer index on associative array
Mike Aubury <[email protected]>
| Newsgroups | gmane.comp.lang.4gl.aubit.general |
|---|---|
| Message-ID | <CAGAq4WE8ty4x+F6oAzCsNqJBiqh2CL30mxzn5iDbq4PrS8Cjdw@mail.gmail.com> |
Associative arrays need to have a simple character variable for their
subscript - they work completely differently from normal arrays - so you
cant using the old '[' ']' for the subscripts.
I'm not sure what you're after - but you can easily convert an integer to a
character string - so how about something like :
FOR *idx*=1 TO 10 # Incr integer index over array.
LET adx=idx USING "&&&&"
IF *a_ohvalue**<<adx*>> IS NOT NULL
THEN
LET other_var=*a_ohvalue**<<adx*>>
END IF
END FOR
Although - I dont think thats what you are after!
As far as I know - from 4gl - theres no current way to iterate over an
associative array - so you might be better off to create a temp table or
something similar ?
On 14 January 2013 20:49, spencertk <[email protected]> wrote:
> **
> Is it possible to use an integer index on the storage variable in an
> associative array? For instance:
>
>
> DEFINE *a_ohvalue* ASSOCIATE CHAR(4) WITH ARRAY[100] OF DECIMAL(15,2)
>
> DEFINE adx CHAR(4) # Alpha index.
> DEFINE *idx* INTEGER # Integer index.
>
> LET adx="MSP" # Set alpha index value.
>
> LET a_ohvalue<<adx>>=10.00 # Store value with alpha index.
>
> #
> # Now switch to integer index on the array. If contents non-null, use the
> stored value.
> #
> FOR *idx*=1 TO 100 # Incr integer index over array.
>
> IF *a_ohvalue*[*idx*] IS NOT NULL
> THEN
> LET other_var=*a_ohvalue*[*idx*]
> END IF
>
> END FOR
>
>
> The idea is to accumulate with IF/NULL logic and then loop through the
> array with a simple loop to dump it's contents.
>
> When I compile code using this method it throws a Segmentation fault.
> Please advise if alternate method.
>
> Spence
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122412
> _______________________________________________
> Aubit4gl-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
>
>
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss