Normal Topic Populating a Combo Box with an external .txt file (Read 1956 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Populating a Combo Box with an external .txt file
Aug 11th, 2006 at 6:12pm
Print Post Print Post  
I'm having various degrees of success using @Insert to populate a variable with items to fill my combo boxes with PopulateListElement.  It's working well, but I have a few minor questions.

When the final value in the list is selected, the element fills with that value plus the characters ^J.  I find that I can avoid this by ending the list of values with a semicolon, however this then allows the user to select a "blank" at the bottom of the list which fills the element with ^J.  I suppose I can suppress this item/fill with programming, but is there a better way that I'm not aware of?

Secondly, I kinda/sorta remember back in Eriks's designing class that there was a way to have "none" appear as a selection item, which would return no value.  But I've forgotten how this is done.  Is it all hard coded or is "none" some kind of built-in selection somehow?

Anyhoo, for what it's worth, here's my current code:

Code
Select All
// Populates the Labor Category combo box with the contents of LaborCategories.txt

Var vCats as String

vCats = @Insert("LaborCategories.txt")
PopulateListElement(LABOR_CATEGORY_1, vCats) 



And the contents of "LaborCategories.txt" is
Code
Select All
Lead Rigger;Rigger;1 Man Crane Crew;Driver only;Forklift Operator;Laborer;2 Man Crane Crew;Electrician;Foreman;Foreman/Supervisor;Millwright;Supervisor; 



Thanks in advance.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Populating a Combo Box with an external .txt f
Reply #1 - Aug 11th, 2006 at 6:22pm
Print Post Print Post  
^J is how a line break is portrayed in a single line element. If you look at your text file you will see that there is two lines. One with the data and a blank one below it. Remove that blank line so that the file only has one line and you should no longer see a ^J.

The value "None", I believe was actually "Done", which was hard coded into the list and I believe was used in an @PopUpMenu() to say that you were done picking toppings for the pizza. You would hard code the value "None" into your combo box and then if the user selects it clear the combo box.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Populating a Combo Box with an external .txt f
Reply #2 - Aug 11th, 2006 at 6:27pm
Print Post Print Post  
Infinity wrote on Aug 11th, 2006 at 6:12pm:
Secondly, I kinda/sorta remember back in Eriks's designing class that there was a way to have "none" appear as a selection item, which would return no value.  But I've forgotten how this is done.  Is it all hard coded or is "none" some kind of built-in selection somehow?


If you look in the coursebook for the Programming class, you will find the code to which you refer all nicely typed out for you so you don't have to remember it.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Populating a Combo Box with an external .txt f
Reply #3 - Aug 11th, 2006 at 6:28pm
Print Post Print Post  
Quote:
Remove that blank line

Yep, that did the trick.
Quote:
You would hard code the value "None" into your combo box and then if the user selects it clear the combo box.

Done and done.  Thanks Ray!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Populating a Combo Box with an external .txt f
Reply #4 - Aug 11th, 2006 at 6:31pm
Print Post Print Post  
Is the hard-coding of "None" case sensitive?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Populating a Combo Box with an external .txt f
Reply #5 - Aug 11th, 2006 at 6:37pm
Print Post Print Post  
No. In Programming "None" is the same as "NONE".

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Populating a Combo Box with an external .txt f
Reply #6 - Aug 11th, 2006 at 6:54pm
Print Post Print Post  
Quote:
If you look in the coursebook for the Programming class,

But...that's what they'd be expecting me to do!

Quote:
you will find the code to which you refer all nicely typed out for you so you don't have to remember it.

Ah, yes, there it is, page 18.  Thanks.  The asterisk...is that so alphabetizing is ignored?
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Populating a Combo Box with an external .txt f
Reply #7 - Aug 11th, 2006 at 7:23pm
Print Post Print Post  
As I mentioned earlier, I'm using @Insert to hand values from a .txt file to PopulateListElement, during On Form Entry.  I know that once the form is opened, any changes I make to the .txt file do not automatically repopulate the element until I close and reopen the form.  My question is this...if I change the entries in the .txt file while the user has the form open, and then he advances to a new record, will the new values be available in that new record or will he have to totally close and reopen the form again?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Populating a Combo Box with an external .txt f
Reply #8 - Aug 11th, 2006 at 7:58pm
Print Post Print Post  
Quote:
The asterisk...is that so alphabetizing is ignored?


Alphabetizing is not turned off, but the *  is used to force that option to always appear at the top.

Quote:
My question is this...if I change the entries in the .txt file while the user has the form open, and then he advances to a new record, will the new values be available in that new record or will he have to totally close and reopen the form again?


On Form Entry is really On Record Entry so if you add a new entry to the txt file and then advance to another record your combo box should have that new value in it.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Populating a Combo Box with an external .txt f
Reply #9 - Aug 11th, 2006 at 8:08pm
Print Post Print Post  
Super, thanks Ray.
  

**
Captain Infinity
Back to top
IP Logged