Re: DYNAMIC ARRAY
Iwan AB <[email protected]> Sun, 11 Jul 2021 12:27:59 +0700
| Newsgroups | gmane.comp.lang.4gl.aubit.general |
|---|---|
| Message-ID | <CAHJCSm+OzvBm_gPD5Wcok_-sLGmp5-DfzF200HajLTTrdey7OQ@mail.gmail.com> |
Dear Mike,
Yeah, I got your point. But would be awesome if these features can be
implemented in the near future of Aubit4GL as I-4GL does? please... :)
here for an example. It works fine in I-4GL :)
p1.4gl
DATABASE testdb
MAIN
DEFINE ar_table1, ar_table2 DYNAMIC ARRAY OF CHAR(20)
DEFINE i, n SMALLINT
CALL p_getfields("table1")
RETURNING ar_table1
DISPLAY "TABEL: table1"
LET n = FGL_DYNARR_EXTENTSIZE(ar_table1, 1)
FOR i = 1 TO n
DISPLAY ar_table1[i]
END FOR
CALL p_getfields("table2")
RETURNING ar_table2
DISPLAY ""
DISPLAY "TABEL: table2"
LET n = FGL_DYNARR_EXTENTSIZE(ar_table2, 1)
FOR i = 1 TO n
DISPLAY ar_table2[i]
END FOR
END MAIN
p_getfields.4gl
DATABASE testdb
FUNCTION p_getfields(w_tabname)
DEFINE w_tabname, w_colname CHAR(20), w_colno, n SMALLINT
DEFINE ar_fields DYNAMIC ARRAY OF CHAR(20)
ALLOCATE ARRAY ar_fields[1]
DECLARE cur1 CURSOR FOR
SELECT a.colname, a.colno
FROM syscolumns a, systables b
WHERE a.tabid = b.tabid
AND b.tabname = w_tabname
ORDER BY a.colno
LET n = 0
FOREACH cur1 INTO w_colname, w_colno
LET n = n + 1
RESIZE ARRAY ar_fields[n]
LET ar_fields[n] = w_colname
END FOREACH
RETURN ar_fields
END FUNCTION
Regards,
Iwan
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Thu, Jul 8, 2021 at 2:58 PM Mike Aubury <[email protected]> wrote:
> You shouldnt "really" be passing arrays around at all.
> Just put all the code using it into a single module and use a module level
> variable for it to keep it all contained..
>
>
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
> www.avg.com
> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_460994264290590454_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Thu, 8 Jul 2021 at 07:46, Iwan AB <[email protected]> wrote:
>
>> Hi,
>>
>> I found quite interesting that in Aubit4GL, dynamic array can be used
>> with INPUT ARRAY or DISPLAY ARRAY statements -- excellent!!, contrary to
>> Informix-4GL (I used I-4GL 7.32), as stated in reference manual that
>> dynamic array cannot be used with INPUT ARRAY or DISPLAY ARRAY statements.
>> But, in Informix-4GL, dynamic array can be passed to or returned from
>> functions. I tested in Aubit4GL, it's said that passing dynamic array to a
>> function is not implented yet.
>>
>> Assertion failed: passing dynamic arrays is not implemented yet
>> (File:dynmem.c Line:178)
>> Err:Program pa.4ge stopped at 'pa.4gl', line number 5.
>> Error status number -30289.
>> Assertion failed.
>>
>> I try using COPYOF
>>
>> MAIN
>> DEFINE a DYNAMIC ARRAY OF CHAR(1)
>> ALLOCATE ARRAY a[1]
>> LET a[1] = "A"
>> #CALL p1(a)
>> CALL p2(COPYOF(a))
>> END MAIN
>>
>> {
>> FUNCTION p1(b)
>> DEFINE b DYNAMIC ARRAY OF CHAR(1)
>> DISPLAY b[1]
>> END FUNCTION
>> }
>>
>> FUNCTION p2(COPYOF b)
>> DEFINE b DYNAMIC ARRAY OF CHAR(1)
>> DISPLAY b[1]
>> END FUNCTION
>>
>> it came up with the following errot at runtime
>>
>> 4gl function call stack :
>> MAIN
>>
>> Err:Program pa.4ge stopped at 'pa.4gl', line number 16.
>> Error status number -30284.
>> Invalid conversion.
>>
>> 4gl function call stack :
>> pa.4gl (Line 6) calls p2(b=Not printable)
>> MAIN
>>
>> Regards,
>>
>> Iwan
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>> <#m_460994264290590454_m_-1151946136569213359_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>> _______________________________________________
>> Aubit4gl-discuss mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
>>
>
_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss