Home > Archive > Programming with dBASE > December 2005 > array expression amendment









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author array expression amendment
Moses Hanna

2005-12-01, 7:23 am

Hi
I have a combobox with an array as datasource
I want to change one of the expressions stored in the array that is
displayed in the combobox
field part. Any help how to do that
Thanks
Moses


Roland Wingerter

2005-12-01, 7:23 am

Moses Hanna wrote

> Hi
> I have a combobox with an array as datasource
> I want to change one of the expressions stored in the array that is
> displayed in the combobox
> field part. Any help how to do that

--------
Create your array as a custom property of the form or the combobox, for
example

function COMBOBOX1_onOpen
this.array = & #123;'one','two','th
ree','four','five'}
this.datasource := "Array this.array"
return

Then you can manipulate the elements of the array anytime. To update the
combobox, just restate its datasource. See sample below.

** END HEADER -- do not remove this line
//
// Generated on 01.12.2005
//
parameter bModal
local f
f = new mosesForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class mosesForm of FORM
with (this)
height = 16.0
left = 53.0
top = 0.0
width = 47.8571
text = "Editing combobox datasource array"
endwith

this.COMBOBOX1 = new COMBOBOX(this)
with (this.COMBOBOX1)
onChange = class::COMBOBOX1_ONC
HANGE
onOpen = class::COMBOBOX1_ONO
PEN
height = 1.0
left = 7.0
top = 1.5
width = 27.0
style = 2 // DropDownList
endwith

this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
onOpen = class::ENTRYFIELD1_O
NOPEN
height = 1.0
left = 7.0
top = 5.5
width = 16.0
value = ""
endwith

this.PB_CHANGE = new PUSHBUTTON(this)
with (this.PB_CHANGE)
onClick = class::PB_CHANGE_ONC
LICK
height = 1.0909
left = 23.0
top = 5.5
width = 17.0
text = "Change value"
endwith


function COMBOBOX1_onChange
form.entryfield1.value := this.value
return

function COMBOBOX1_onOpen
this.array = & #123;'one','two','th
ree','four','five'}
this.datasource := "Array this.array"
return

function ENTRYFIELD1_onOpen
this.value := form.combobox1.value
return

function PB_CHANGE_onClick
cNewValue = form.entryfield1.value.LeftTrim().RightTrim()
if not empty(cNewValue)
cValue = form.combobox1.value
n = form.combobox1.array.scan(cValue)
form.combobox1.array[n] = cNewValue
form.combobox1.datasource := "ARRAY form.combobox1.array"
form.combobox1.value := cNewValue
endif
return

endclass


Moses Hanna

2005-12-03, 3:23 am

Thanks Roland
Moses

"Roland Wingerter" <ich@hier.de> wrote in message
news:pP0CMum9FHA.1520@news-server...
> Moses Hanna wrote
> --------
> Create your array as a custom property of the form or the combobox, for
> example
>
> function COMBOBOX1_onOpen
> this.array = & #123;'one','two','th
ree','four','five'}
> this.datasource := "Array this.array"
> return
>
> Then you can manipulate the elements of the array anytime. To update the
> combobox, just restate its datasource. See sample below.
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 01.12.2005
> //
> parameter bModal
> local f
> f = new mosesForm()
> if (bModal)
> f.mdi = false // ensure not MDI
> f.readModal()
> else
> f.open()
> endif
>
> class mosesForm of FORM
> with (this)
> height = 16.0
> left = 53.0
> top = 0.0
> width = 47.8571
> text = "Editing combobox datasource array"
> endwith
>
> this.COMBOBOX1 = new COMBOBOX(this)
> with (this.COMBOBOX1)
> onChange = class::COMBOBOX1_ONC
HANGE
> onOpen = class::COMBOBOX1_ONO
PEN
> height = 1.0
> left = 7.0
> top = 1.5
> width = 27.0
> style = 2 // DropDownList
> endwith
>
> this.ENTRYFIELD1 = new ENTRYFIELD(this)
> with (this.ENTRYFIELD1)
> onOpen = class::ENTRYFIELD1_O
NOPEN
> height = 1.0
> left = 7.0
> top = 5.5
> width = 16.0
> value = ""
> endwith
>
> this.PB_CHANGE = new PUSHBUTTON(this)
> with (this.PB_CHANGE)
> onClick = class::PB_CHANGE_ONC
LICK
> height = 1.0909
> left = 23.0
> top = 5.5
> width = 17.0
> text = "Change value"
> endwith
>
>
> function COMBOBOX1_onChange
> form.entryfield1.value := this.value
> return
>
> function COMBOBOX1_onOpen
> this.array = & #123;'one','two','th
ree','four','five'}
> this.datasource := "Array this.array"
> return
>
> function ENTRYFIELD1_onOpen
> this.value := form.combobox1.value
> return
>
> function PB_CHANGE_onClick
> cNewValue = form.entryfield1.value.LeftTrim().RightTrim()
> if not empty(cNewValue)
> cValue = form.combobox1.value
> n = form.combobox1.array.scan(cValue)
> form.combobox1.array[n] = cNewValue
> form.combobox1.datasource := "ARRAY form.combobox1.array"
> form.combobox1.value := cNewValue
> endif
> return
>
> endclass
>



Roland Wingerter

2005-12-05, 3:23 am

Moses Hanna wrote

> Thanks Roland

------
You are welcome, Moses.

Roland


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com