Array Expression or Method in Fillusing

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Anonymous

Array Expression or Method in Fillusing

Post by Anonymous »

Each Record has 3 contact name fields and associated phone numbers and email addresses - Main, Sales and Rep. I'd like to have a ComboBox filled with the three field values for each record, which changes as the user moves through the records (so the list only ever has a maximum of 3 members). Is this possible? I'm playing around with this code at the moment, and it doesn't work.

Method ContactsList Class DataWindow
Local aRay as Array
aRay := {}
AAdd(aRay, self:server:FIELDGET(#CLCONTACT)) <----CLEMAIL and CLEmail associated
Aadd(aRay, self:server:FieldGet(#SCONTACT)) <---- SEMAIL and SPhone associated
AAdd(aRay, self:server:FIELDGET(#REPCONTACT)) < ------ RepEmail and RepPhone associated
return aRay


What am I doing wrong please. I've used Arrays before, but not in this type of use. Can it be done, and if so how please.

Thanks again.
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Array Expression or Method in Fillusing

Post by lumberjack »

Hi Jeff,

Code: Select all

Method ContactsList Class DataWindow  
Local aRay as Array
aRay := {}  
AAdd(aRay, {self:server:FIELDGET(#CLCONTACT)) , ;
                     self:server:FieldGet(#SCONTACT) + " - " + ;// <---- SEMAIL and SPhone associated
                     self:server:FIELDGET(#REPCONTACT)}) //    < ------ RepEmail and RepPhone associated
return aRay
What am I doing wrong please. I've used Arrays before, but not in this type of use. Can it be done, and if so how please.
I think the ListBox wants a two dimensional array and uses aRay[1], aRay[2] for value and display fields. Otherwise you will have to use a listview control to emulate the ListBox. You also need to:

Code: Select all

oComboBox:FillUsing(aRay)
______________________
Johan Nel
Boshof, South Africa
BiggyRat

Array Expression or Method in Fillusing

Post by BiggyRat »

Thanks Johan, maybe I'm doing something wrong? Not unusual for me, as I'm sure you all know...

I changed the code to:

AAdd(aRay, {self:server, self:Server})
AAdd(aRay, {self:Server:FIELDGET(#CLCONTACT), self:Server:FIELDGET(#CLCONTACT)})
AAdd(aRay, {self:Server:FIELDGET(#SCONTACT), self:Server:FIELDGET(#SCONTACT)})
AAdd(aRay, { self:Server:FIELDGET(#REPCONTACT), self:Server:FIELDGET(#REPCONTACT)})

and I get the same error:
ArrayJPG.JPG
ArrayJPG.JPG (23.91 KiB) Viewed 637 times
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Array Expression or Method in Fillusing

Post by lumberjack »

Hi Jeff,
BiggyRat wrote:

Code: Select all

AAdd(aRay, {self:server, self:Server}) 
Is this line 4? Does not make sense to have the server in the aRay...
AFAIK you can pass a single or double dimension array into FillUsing, but self:server does not make sense
______________________
Johan Nel
Boshof, South Africa
BiggyRat

Array Expression or Method in Fillusing

Post by BiggyRat »

Of course! That has to be it. Thanks very much Johan. I'll give that a try now. I put it there originally to make sure I was on the right server...
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Array Expression or Method in Fillusing

Post by lumberjack »

Hi Jeff,
Obviously using AAdd() from a purist perspective will have a bit of a speed penalty. You can also just assign the array as follows:

Code: Select all

Method ContactsList Class DataWindow  
Local aRay as Array
aRay := {self:server:FIELDGET(#CLCONTACT) , ;
               self:server:FieldGet(#SCONTACT), ;
               self:server:FIELDGET(#REPCONTACT)}
return aRay
Or if you want the 2 dimensional array:

Code: Select all

aRay := {{self:Server:FIELDGET(#CLCONTACT), self:Server:FIELDGET(#CLCONTACT)}, ;
               {self:Server:FIELDGET(#SCONTACT), self:Server:FIELDGET(#SCONTACT)}, ;
               {self:Server:FIELDGET(#REPCONTACT), self:Server:FIELDGET(#REPCONTACT)}}
______________________
Johan Nel
Boshof, South Africa
BiggyRat

Array Expression or Method in Fillusing

Post by BiggyRat »

Thanks Johan, unfortunately I still can't get it to work. Using your code, I get this error:
Array Fillusing.JPG
Array Fillusing.JPG (25.26 KiB) Viewed 637 times
I think it's the same error I was getting earlier with my code. What is wrong? All I have done is put a combobox on my form and told it to FillUsing ContactsList. If this helps, I don't know but even though in your example you used Class DataWindow, I tried Class JobInfo - the actual screen the control is on, and self:server returns NULL,,,, How can that be when the Server attached to the JobInfo window IS CLIENTS?
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Array Expression or Method in Fillusing

Post by lumberjack »

Jeff,
Why is ContactsList part of DataWindow and not JobInfo?
I suggest you change it to METHOD ContactsList() CLASS JobInfo.
______________________
Johan Nel
Boshof, South Africa
BiggyRat

Array Expression or Method in Fillusing

Post by BiggyRat »

LOL because of your code! :) I've done exactly as you suggested Johan, but same error. I don't get it.

Method ContactsList() Class JobInfo
Local aRay as Array
aRay := {self:server:FIELDGET(#CLCONTACT) , ;
self:server:FIELDGET(#SCONTACT), ;
self:server:FIELDGET(#REPCONTACT)}
return aRay
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Array Expression or Method in Fillusing

Post by lumberjack »

Jeff,
Also without seeing your JobInfo:Init() code, are you sure you attached the server before you call ContactsList?
______________________
Johan Nel
Boshof, South Africa
Post Reply