--
Nancy Gleaton
Charter Member 0123
nanc...@successpath.net
Remove _ns before sending email
>When a combobox's datasource is an array, and you've typed in the values
>for the array, how do you address the individual array elements? I know
>if you define an array "a = new Array(x,y)" you can say "a[x,y]", but
>what's the name of the literal array in the datasource?
That's the problem of using a literal array as datasource. You can't
really do what you want. The solution is to create a "real" array for
use as the datasource.
Gary White [dBVIPS]
Some dBASE Stuff at
http://www.apptools.com/dbase
> if you define an array "a = new Array(x,y)" you can say "a[x,y]", but
> what's the name of the literal array in the datasource?
Do you mean something like this?
** END HEADER -- do not remove this line
//
// Generated on 04/10/2000
//
parameter bModal
local f
f = new testForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class testForm of FORM
with (this)
height = 16
left = 29.5714
top = -0.4545
width = 40
text = ""
endwith
this.COMBOBOX1 = new COMBOBOX(this)
with (this.COMBOBOX1)
onChange = class::COMBOBOX1_ONCHANGE
height = 1
left = 11.2857
top = 1.9091
width = 12
dataSource = 'array {"a","b","c","d","e","f","g","h"}'
style = 1 // DropDown
endwith
this.TEXTLABEL1 = new TEXTLABEL(this)
with (this.TEXTLABEL1)
height = 1
left = 3
top = 11.7273
width = 34.2857
text = ""
endwith
this.TEXTLABEL2 = new TEXTLABEL(this)
with (this.TEXTLABEL2)
height = 1
left = 3
top = 13.4545
width = 34.2857
text = ""
endwith
function COMBOBOX1_onChange
form.textlabel1.text = this.datasource
form.textlabel2.text = this.value
return
endclass
Regards,
Fred
class tpgForm of FORM
with (this)
onOpen = class::ONOPEN
height = 7.0909
left = 31.1429
top = 5
width = 40
text = ""
endwith
this.CB1 = new COMBOBOX(this)
with (this.CB1)
height = 1
left = 0.1429
top = 0.1818
width = 40
id = 101
dataSource = 'array {"P1","P3","P3","P4","P5"}'
style = 1 // DropDown
endwith
Function OnOpen
clear
private a
a=form.cb1.datasource
a=right(a,a.length-6)
a=&a.
for n=1 to a.size
? a[n]
next
endclass
--
Romain Strieff [dBVIPS]
News group posting guidelines at
http://www.dbase.com/cnt/newsguid.htm
> Hello Nancy,
>
> > if you define an array "a = new Array(x,y)" you can say "a[x,y]", but
> > what's the name of the literal array in the datasource?
>
> Do you mean something like this?
What I really want to do is know which array item was picked in the
combobox based on the text value it's equal to.
Nancy L. Gleaton je v sporočilu novic napisal ...
> What I really want to do is know which array item was picked in the
> combobox based on the text value it's equal to.
Below is a little modified example of Romain, which shows in the command window
what you want.
Marko
** END HEADER -- do not remove this line
//
// Generated on 04.10.2000
//
parameter bModal
local f
f = new tpgForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class tpgForm of FORM
with (this)
onOpen = {||form.array_item()}
height = 7
left = 35
top = 0
width = 40
text = "Nancy - which array item selected"
endwith
this.CB1 = new COMBOBOX(this)
with (this.CB1)
onChange = {||form.array_item()}
left = 13
top = 3
dataSource = 'array {"P1","P2","P3","P4","P5"}'
endwith
function array_item
private a
a=form.cb1.datasource
a=right(a,a.length-6)
a=&a.
for n=1 to a.size
if trim(form.CB1.value)==a[n]
? 'I am array item:'+n
endif
next
return
endclass
> function array_item
> private a
> a=form.cb1.datasource
> a=right(a,a.length-6)
> a=&a.
> for n=1 to a.size
> if trim(form.CB1.value)==a[n]
> ? 'I am array item:'+n
Why not use a.scan() instead of the For...Next ?
--
Peter Rorlick [dBVIPS]
Montreal Business Software
> > function array_item
> > private a
> > a=form.cb1.datasource
> > a=right(a,a.length-6)
> > a=&a.
> > for n=1 to a.size
> > if trim(form.CB1.value)==a[n]
> > ? 'I am array item:'+n
>
> Why not use a.scan() instead of the For...Next ?
Good catch. I may say in my defence only that I just didn't want to make a total
alteration of the Romain's original example. <g&d>
Marko