Array population thing I just spotted...

26 views
Skip to first unread message

Adrian Williamson

unread,
Apr 4, 2024, 10:10:21 AM4/4/24
to openroa...@googlegroups.com

initialize()=

declare

Bob = array of StringObject;

Kate = array of StringObject;

Enddeclare

Begin

      Bob[1].Value = ‘I work OK’;

      Kate[1].ConcatVarchar(text = ‘I do not – I say E_WT0033 Row 1 is out of range for an array access’);

End;

 

I just spotted this messing about with JSONObject and the URLConnection class.

 

A class attribute reference makes me a Stringobject in the array first, but not a method invocation.

 

It is possible that I have never tried using a Method invocation in a ‘First Assignment’ context in the last 33 years.

 

Must be all this Python corrupting my mind.

 

Cheers

 

Adrian

 

https://docs.actian.com/openroad/11.2/index.html#page/Programming/How_You_Can_Manipulate_Arrays.htm#ww394976

 

 

 

 

 

 

 

 

image002.png

Bodo Bergmann

unread,
Apr 4, 2024, 10:21:19 AM4/4/24
to openroa...@googlegroups.com
This is expected (and documented) behavior.
You cannot invoke a method on a non-existing object.
But when you assign an attribute on an array row that has an index of lastrow+1, then a new object is automatically created (and assigned to that row) before assigning the attribute value.
This has been the behavior since the beginning of OpenROAD (Windows/4GL in the late 1980s 😀) .

Cheers,
Bodo

Bodo Bergmann

Engineering Architect | OpenROAD Engineering

Actian, a division of HCLSoftware

actian.com    hcl-software.com

 GESELLSCHAFTSANGABEN: Actian Germany GmbH | Registry Off: Halenreie 42, 22359 Hamburg | Geschäftsführung: Stephen Padgett, Marc Monahan | HandelsregisterAmtsgericht Hamburg | HRB 135991 | USt-IdNr: DE252449897 


--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/001701da8699%24d24645f0%2476d2d1d0%24%40rationalcommerce.com.

Adrian Williamson

unread,
Apr 4, 2024, 11:04:04 AM4/4/24
to openroa...@googlegroups.com

> You cannot invoke a method on a non-existing object.

 

Or an attribute access on a non existent object – but the array code has a special case for attribute access and does it for you, but not for the method.

 

The lack of symmetry made me pause, but I did this:

 

                wwwheaders[2].value = '';

                wwwheaders[2].ConcatVarchar(text = 'Authorization: Bearer ' ) ;

 

While I have your attention:

 

This Curl  with the -d daisy chained text:

 

                /*

                curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \

                https://login.microsoftonline.com/your_tenant_id/oauth2/token\

                -d 'client_id=your_app_client_id' \

                -d 'grant_type=client_credentials' \

                -d 'resource=wwws://management.azure.com/' \

                -d 'client_secret=*******************'

                */

 

In OpenROAD I got it working like so with ampersands:

 

                PostData.Concatvarchar(text ='&client_id=0af2e49f-73bc-466b-8ca5-6e7b91e251ab' );

                PostData.Concatvarchar(text ='&grant_type=client_credentials' );

                PostData.Concatvarchar(text ='&resource=https://management.azure.com/'  );

                PostData.Concatvarchar(text ='&client_secret=2.D8Q~Ml5x_IlB4eK_kFt7VfI3D2y2H8vHZAsaQd'  );

                                                            

                //CurExec.Trace(string = PostData);

               

                /* Nope, does not work like the -d shown above

                www.SetOption(option = CURLOPT_POSTFIELDS, value = 'client_id=<some garbage>');

                www.SetOption(option = CURLOPT_POSTFIELDS, value = 'grant_type= client_credentials ');

                www.SetOption(option = CURLOPT_POSTFIELDS, value = 'resource=https://management.azure.com/');

                www.SetOption(option = CURLOPT_POSTFIELDS, value = 'client_secret=<more garbage>');           

                */

 

Should I have passed an array of StringObject for that?

 

I got it working and carried on – but seeing as you are here….

 

Cheers

 

Adrian

PS I thought this google group was supposed to stop working?

 

 

From: openroa...@googlegroups.com <openroa...@googlegroups.com> On Behalf Of Bodo Bergmann
Sent: 04 April 2024 15:21
To: openroa...@googlegroups.com
Subject: Re: [openroad-users] Array population thing I just spotted...

 

This is expected (and documented) behavior.
You cannot invoke a method on a non-existing object.
But when you assign an attribute on an array row that has an index of lastrow+1, then a new object is automatically created (and assigned to that row) before assigning the attribute value.
This has been the behavior since the beginning of OpenROAD (Windows/4GL in the late 1980s 😀) .

 

Cheers,

Bodo

Bodo Bergmann

Engineering Architect | OpenROAD Engineering

Actian, a division of HCLSoftware

actian.com    hcl-software.com

Image removed by sender.

image001.jpg
image002.png

Bodo Bergmann

unread,
Apr 4, 2024, 11:38:08 AM4/4/24
to openroa...@googlegroups.com
Hi Adrian,

You got it correctly using the different fields connected by ampersand.
The CURLOPT_POSTFIELDS option expects one string (varchar or nvarchar), not an array
(see https://docs.actian.com/openroad/11.2/index.html#page/LangRef/UrlConnection__22option_22_Settings.htm).
The data must be formatted and encoded the way you want the server to receive it.

The "curl" utility just joins multiple "-d" options together with ampersand as separator.

Bodo

Adrian Williamson

unread,
Apr 4, 2024, 11:42:28 AM4/4/24
to openroa...@googlegroups.com
image001.jpg
image002.png
Reply all
Reply to author
Forward
0 new messages