fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC: Array Expression or Method in Fillusing

Array Expression or Method in Fillusing 1 week 8 hours ago #10155

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
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.

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 1 week 7 hours ago #10156

  lumberjack's Avatar lumberjack Offline Posts: 513
Hi Jeff,
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:
oComboBox:FillUsing(aRay)
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Last edit: by lumberjack.

Array Expression or Method in Fillusing 1 week 6 hours ago #10157

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
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:

Attachments:

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 1 week 6 hours ago #10158

  lumberjack's Avatar lumberjack Offline Posts: 513
Hi Jeff,

BiggyRat wrote:

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
George, South Africa

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 1 week 6 hours ago #10159

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
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...

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 14 hours ago #10160

  lumberjack's Avatar lumberjack Offline Posts: 513
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:
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:
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
George, South Africa

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 14 hours ago #10161

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
Thanks Johan, unfortunately I still can't get it to work. Using your code, I get this error:



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?
Attachments:

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 14 hours ago #10162

  lumberjack's Avatar lumberjack Offline Posts: 513
Jeff,
Why is ContactsList part of DataWindow and not JobInfo?
I suggest you change it to METHOD ContactsList() CLASS JobInfo.
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 14 hours ago #10163

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
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

Please Log in or Create an account to join the conversation.

Last edit: by BiggyRat.

Array Expression or Method in Fillusing 6 days 14 hours ago #10164

  lumberjack's Avatar lumberjack Offline Posts: 513
Jeff,
Also without seeing your JobInfo:Init() code, are you sure you attached the server before you call ContactsList?
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Last edit: by lumberjack.

Array Expression or Method in Fillusing 6 days 14 hours ago #10165

  lumberjack's Avatar lumberjack Offline Posts: 513
Jeff,

BiggyRat wrote: LOL because of your code! :)

Nope not my code, check you original posting, it was DataWindow... :cheer:
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 12 hours ago #10166

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
D'Oh! Sorry, my bad. Thank you Johan, you put me on the right track. I thought it had something to do with the order of things somewhere. I foolishly thought VO would create the init file with things in the correct order.. I moved that section of code to immediately after when the server is attached, and it worked.... MOSTLY.

Now, all I have to do is work out how to rebuild the array when the record changes...

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 12 hours ago #10167

  lumberjack's Avatar lumberjack Offline Posts: 513
Jeff,

BiggyRat wrote: Now, all I have to do is work out how to rebuild the array when the record changes...

How is the record number changing? Behind a Skip button(s)?
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 11 hours ago #10168

  Karl-Heinz's Avatar Karl-Heinz Offline Posts: 317

BiggyRat wrote: Now, all I have to do is work out how to rebuild the array when the record changes...


Hi Jeff,

you can do that in the Window Notify() method.

METHOD Notify( kNotifyName , uDescription ) CLASS yourwin
LOCAL xRet AS USUAL

	xRet := SUPER:Notify( kNotifyName , uDescription )	
	
	IF kNotifyName >= NotifyRecordChange .AND. kNotifyName <= NotifyGoTop

          self:FillComboBox()


	ENDIF

	
	RETURN xRet


Method FillComboBox() class yourwin	

oYourCmb:fillusing ( {{self:Server:FIELDGET(#CLCONTACT), self:Server:FIELDGET(#CLCONTACT)}, ;
               {self:Server:FIELDGET(#SCONTACT), self:Server:FIELDGET(#SCONTACT)}, ;
               {self:Server:FIELDGET(#REPCONTACT), self:Server:FIELDGET(#REPCONTACT)}} )

oYourCmb:currentitemno := 1

return self

But honestly, i don´t understand what you are trying to achieve, when you fill each time the record pointer is moved a comboxbox with self:server content ? What happens if the user selects a combobox item ?

regards
Karl-Heinz

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 11 hours ago #10169

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 197
"How is the record number changing? Behind a Skip button(s)?" Exactly Johan. I have sorted it out though thank you very much again for your help.

"But honestly, i don´t understand what you are trying to achieve, when you fill each time the record pointer is moved a comboxbox with self:server content ? What happens if the user selects a combobox item ?"

As I said in my initial post Karl-Heinz, each Company record has up to 3 contacts, each with their own email address and phone number. On my window I have 2 fixed texts - EmailTxt and PhoneTxt Based on the selected item in the ComboBox, I assign the appropriate email and phone details as captions to those fixed texts. That way the user can select which contact they want for that company, without having to switch screens...

This should show you EXACTLY what's going on:

cl.ly/30d9b94cd2d5

Please Log in or Create an account to join the conversation.

Last edit: by BiggyRat.

Array Expression or Method in Fillusing 6 days 10 hours ago #10170

  Karl-Heinz's Avatar Karl-Heinz Offline Posts: 317
ok, i got it :-)

regards
Karl-Heinz

Please Log in or Create an account to join the conversation.

Array Expression or Method in Fillusing 6 days 10 hours ago #10171

  lumberjack's Avatar lumberjack Offline Posts: 513

BiggyRat wrote: "How is the record number changing? Behind a Skip button(s)?" Exactly Johan. I have sorted it out though thank you very much again for your help.

Glad we could be of help.

As I said in my initial post Karl-Heinz, each Company record has up to 3 contacts, each with their own email address and phone number. On my window I have 2 fixed texts - EmailTxt and PhoneTxt Based on the selected item in the ComboBox, I assign the appropriate email and phone details as captions to those fixed texts. That way the user can select which contact they want for that company, without having to switch screens...
This should show you EXACTLY what's going on:

Thanks for sharing, I do understand what you want to achieve, was just a bit of effort to get behind the code logic. Well done and good luck with the rest... We waiting in anticipation for the next challenge :P
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Last edit: by lumberjack.
  • Page:
  • 1