Subject |
Re: Control passing back and fro in a form sub routine |
From |
Akshat Kapoor <akshat.kapoor@kapoorsons.in> |
Date |
Wed, 26 Jul 2023 11:03:02 +0530 |
Newsgroups |
dbase.getting-started |
Good Morning Milind,
>> ** END HEADER -- do not remove this line
>> //
>> // Generated on 2023-07-25
>> //
>> parameter bModal
>> local f
>> f = new squareForm()
>> if (bModal)
>> f.mdi = false // ensure not MDI
>> f.readModal()
>> else
>> f.open()
>> endif
>>
>> class squareForm of FORM
>> with (this)
>> onOpen = class::FORM_ONOPEN
>> height = 16.0
>> left = 7.4286
>> top = 1.6818
>> width = 40.0
>> text = ""
>> endwith
>>
>> this.ENTRYFIELD1 = new ENTRYFIELD(this)
>> with (this.ENTRYFIELD1)
>> onGotFocus = class::ENTRYFIELD1_ONGOTFOCUS
>> height = 1.0
>> left = 16.0
>> top = 4.0455
>> width = 8.0
>> value = ""
>> endwith
>>
>> this.PUSHBUTTON1 = new PUSHBUTTON(this)
>> with (this.PUSHBUTTON1)
>> onClick = class::PUSHBUTTON1_ONCLICK
>> height = 1.0909
>> left = 13.0
>> top = 7.4091
>> width = 15.2857
>> text = "Calculate square"
>> endwith
>>
>> this.ENTRYFIELD2 = new ENTRYFIELD(this)
>> with (this.ENTRYFIELD2)
>> height = 1.0
>> left = 16.0
>> top = 10.4545
>> width = 8.0
>> value = ""
>> endwith
>>
>>
>> function ENTRYFIELD1_onGotFocus()
>> this.value = ''
>> form.entryfield2.value = ''
>> return
>>
>> function PUSHBUTTON1_onClick()
>> //Because the default value of entryfield1 has been set to blank
>> //dBASE sees any value entered as a character. VAL() is used to
>> //convert the character(s) to numeric values.
>> form.entryfield2.value = square(val(form.entryfield1.value))
>> return
>>
>> function form_onOpen()
>> set procedure to square.prg
Passing control to square.prg is no issue. Passing value back to form is
also not an issue. But passing value back to the form in between is an
issue.
You can say
Form.text1.text = square(X)
The value returned by square.prg will be displayed. I am posting code
BUT it may cause complications due to use of Public variables.
Public mform
mform = form
What happens to form after the end of the form is untested. It will be
released from memory or not I cannot say.
>> return
>>
>> endclass
>>
>> function square(nVal)
>> local retVal
>> retVal = nVal*nVal
> return retVal
>
>
> Mevin to clarify myslef I want to build scenerio on your example itself
>
> You have used set procedure to square.prg. I want to put something like this
>
> function square(nVal)
> local retVal
> do while nVal < = 5
> retVal = nVal*nVal
/*
mform.text1.text = "some Value"
*/
> *Display nVal onto the form and come baclk
>
> nVal = nVal+1
> endd
> return retVal
>
> here I want to go to square.form and display nVal onto the
> *form and come back for next nVal
>
> Hope I clarify
Regards
Akshat
|