In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

TMaskedit and array values.

Xailer English public forum
Responder
Mike Evans
Mensajes: 7
Registrado: Vie May 30, 2008 3:51 pm

TMaskedit and array values.

Mensaje por Mike Evans »

We have the following situation. We need to convert a Clipper application
tha uses arrays to load data. The clipper get system uses this array and
then on exit we use the array to save the record. It's not possible to
change this structure because we use the array values to make calculations
(thousands of lines of heavily checked calculations). Is it possible to do
the same with Xailer? Each TMaskedit get the value from an array element
and the changed value of TMaskedit must change the array element again.
Thanks in advance
Mike Evans
Gejza Horvath
Mensajes: 281
Registrado: Mar Ago 15, 2006 1:50 pm

TMaskedit and array values.

Mensaje por Gejza Horvath »

What about load a TMaskEdit:Value property into array?
The Tform object has an aControls array property, which holds the references to all
controls on the form. Creating a copy from elements of the Tform:aControls where the
oControl is kind of TMaskEdit class could be the array, you are looking for.
The code is not tested:
METHOD LoadValues() CLASS TForm1
LOCAL oControl
// aValues is a PROPERTY of TForm1
// PROPERTY aValues
::aValues := {}
FOR EACH oControl IN ::aControls
IF oControl:IsKindOf("TMaskEdit")
/* here we add only a reference to the orginal control */
AADD(aValues,oControl)
ENDIF
NEXT
Somwhere later in your code you can get the value
xValue := ::aValues:Value
or set the value
::aValues:Value := xValue
Hope this helps.
Gejza Horvath
"Mike Evans" <makis1970@hotmail.com> pí¹e v diskusním pøíspìvku
news:ocdcko2t4hg8$[email=.7pz41uomf4dm.dlg@40tude.net...].7pz41uomf4dm.dlg@40tude.net...[/email]
> We have the following situation. We need to convert a Clipper application
> tha uses arrays to load data. The clipper get system uses this array and
> then on exit we use the array to save the record. It's not possible to
> change this structure because we use the array values to make calculations
> (thousands of lines of heavily checked calculations). Is it possible to do
> the same with Xailer? Each TMaskedit get the value from an array element
> and the changed value of TMaskedit must change the array element again.
>
> Thanks in advance
> Mike Evans
>
Mike Evans
Mensajes: 7
Registrado: Vie May 30, 2008 3:51 pm

TMaskedit and array values.

Mensaje por Mike Evans »

On Tue, 3 Jun 2008 21:30:44 +0100, Gejza Horvath wrote:
> What about load a TMaskEdit:Value property into array?
> The Tform object has an aControls array property, which holds the references to all
> controls on the form. Creating a copy from elements of the Tform:aControls where the
> oControl is kind of TMaskEdit class could be the array, you are looking for.
>
> The code is not tested:
>
> METHOD LoadValues() CLASS TForm1
> LOCAL oControl
>
> // aValues is a PROPERTY of TForm1
> // PROPERTY aValues
>
>::aValues := {}
> FOR EACH oControl IN ::aControls
> IF oControl:IsKindOf("TMaskEdit")
> /* here we add only a reference to the orginal control */
> AADD(aValues,oControl)
> ENDIF
> NEXT
>
> Somwhere later in your code you can get the value
>
> xValue := ::aValues:Value
>
> or set the value
> ::aValues:Value := xValue
>
> Hope this helps.
>
> Gejza Horvath
>
> "Mike Evans" <makis1970@hotmail.com> pí­Â¹e v diskusní­m pí¸í­spí¬vku
> news:ocdcko2t4hg8$[email=.7pz41uomf4dm.dlg@40tude.net...].7pz41uomf4dm.dlg@40tude.net...[/email]
>> We have the following situation. We need to convert a Clipper application
>> tha uses arrays to load data. The clipper get system uses this array and
>> then on exit we use the array to save the record. It's not possible to
>> change this structure because we use the array values to make calculations
>> (thousands of lines of heavily checked calculations). Is it possible to do
>> the same with Xailer? Each TMaskedit get the value from an array element
>> and the changed value of TMaskedit must change the array element again.
>>
>> Thanks in advance
>> Mike Evans
>>
Hi Gejza,
Thank for your help but this enormous work for me. We have more than 100
forms (from 2 to 4 pages A4 each one). Each form have from 300 to 1600
fields. What we are doing until now is the following :
We are opening the table and filling (using scatter gather functions) an
array for each table. We have automatically defines for each array
(something like nFRM1_E1354 aFrm1[ 248 ] ). We have also screens with a lot
of gets (@ 10,10 get nFRM1_E1354) and we have also at least one Calculate
function that is called automatically on each get value change Function
Calculate( aFrm1 )
nFRM1_E1354 + nFRM1_K245 etc. The calculations are an enormous work and
we will need more than 2 years to make it in windows way (Object classes
etc). What we want if its possible is each TMaskedit control to have a
datalink property (somethink like get set) {| value | If( Value # Nil,
nFRM1_E1354 := Value, nFRM1_E1354 ) }. Have in mind that we have more than
150.000 fields in out program. We have (even under xHarbour) to use the
same names per field and per database ( DB1 Field1, Field2, Field3, DB2
Field1, Field2, Field3 etc). Also its forms consist from 4 A4 pages and
each one have at least 150 - 400 TMaskedits.
Regards
Mike Evans
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

TMaskedit and array values.

Mensaje por jfgimenez »

Mike,
> We have the following situation. We need to convert a Clipper application
> tha uses arrays to load data. The clipper get system uses this array and
> then on exit we use the array to save the record. It's not possible to
> change this structure because we use the array values to make calculations
> (thousands of lines of heavily checked calculations). Is it possible to do
> the same with Xailer? Each TMaskedit get the value from an array element
> and the changed value of TMaskedit must change the array element again.
I belive that Gejza approach is right. You may write 2 simple routines, one
that is executed after loading data into the array and the other before
writing that array into the DB. I.e.:
METHOD LoadData( aArrayData )
LOCAL oCtl, n := 1
FOR EACH oCtl IN ::aControls
IF n > Len( aArrayData )
EXIT
ENDIF
IF oCtl:IsKindOf( "TMaskEdit" )
oCtl:Value := aArrayData[ n++ ]
ENDIF
NEXT
RETURN Nil
METHOD SaveData( aArrayData )
LOCAL oCtl, n := 1
FOR EACH oCtl IN ::aControls
IF n > Len( aArrayData )
EXIT
ENDIF
IF oCtl:IsKindOf( "TMaskEdit" )
aArrayData[ n++ ] := oCtl:Value
ENDIF
NEXT
RETURN Nil
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Mike Evans
Mensajes: 7
Registrado: Vie May 30, 2008 3:51 pm

TMaskedit and array values.

Mensaje por Mike Evans »

On Tue, 10 Jun 2008 21:50:35 +0200, Jose F. Gimenez wrote:
> Mike,
>
>> We have the following situation. We need to convert a Clipper application
>> tha uses arrays to load data. The clipper get system uses this array and
>> then on exit we use the array to save the record. It's not possible to
>> change this structure because we use the array values to make calculations
>> (thousands of lines of heavily checked calculations). Is it possible to do
>> the same with Xailer? Each TMaskedit get the value from an array element
>> and the changed value of TMaskedit must change the array element again.
>
> I belive that Gejza approach is right. You may write 2 simple routines, one
> that is executed after loading data into the array and the other before
> writing that array into the DB. I.e.:
>
> METHOD LoadData( aArrayData )
> LOCAL oCtl, n := 1
> FOR EACH oCtl IN ::aControls
> IF n > Len( aArrayData )
> EXIT
> ENDIF
> IF oCtl:IsKindOf( "TMaskEdit" )
> oCtl:Value := aArrayData[ n++ ]
> ENDIF
> NEXT
> RETURN Nil
>
> METHOD SaveData( aArrayData )
> LOCAL oCtl, n := 1
> FOR EACH oCtl IN ::aControls
> IF n > Len( aArrayData )
> EXIT
> ENDIF
> IF oCtl:IsKindOf( "TMaskEdit" )
> aArrayData[ n++ ] := oCtl:Value
> ENDIF
> NEXT
> RETURN Nil
Hi Jose,
Think the following situation:
We have 4 Tab pages with an A4 bmp in each tab as background. Each bmp have
at least 200 Tmaskedits in specific position each one. Each maskedit must
associate with a specific array element. On form load we have a functions
that loads all the data on an array. Each element have a spcecific define.
so under dos we are doing the following
// Page1
@ 10, 10 get APG1_0304
@ 12, 13 get APG1_0428
etc.
Those gets are sometimes more than 1000 (for all the pages). Also for each
form ther is a Calculations function :
Function CALC_AFRM1()
APG1_128 := (APG2_1235 * APG3_0321 )/ 100
// thousands of calculation lines with very difficult to reimplement
// with another approach.
Return
What we need is a datalink property in each TMaskedit. This property must
take also defines Datalink := {|xValue| If( xValue == NIL, APG1_0304,
APG1_0304 := xValue) }
Thanks in advance
Mike Evans
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

TMaskedit and array values.

Mensaje por Oleg »

Mike,
> What we need is a datalink property in each TMaskedit. This property must
> take also defines Datalink := {|xValue| If( xValue == NIL, APG1_0304,
> APG1_0304 := xValue) }
maybe you need something like this (a piece of code from my programs)
edit1.prg
---------
CLASS TEDIT FROM XEDIT
PUBLISHED:
DATA bBlock
ENDCLASS
func CFEdit(oForm, nRow, nCol, bBlock, cPicture)
local oObj, aRect, cValue, nLen, cType, oObjDop
cValue:=eval(bBlock)
cType:=valtype(cValue)
if cPicture<>NIL
nLen:=len(transform(cValue, cPicture))
else
if cType=='C'
nLen:=len(cValue)
elseif cType=='N'
nLen:=len(str(cValue))
elseif cType=='D'
nLen:=9
endif
endif
oObj:=TMaskEdit():New( oForm )
WITH OBJECT oObj
:SetBounds(nCol, nRow, CW_EDIT_WIDTH*nLen, CW_EDIT_HEIGHT)
:bBlock:=bBlock
:Value:=cValue
:OnChange:={|x| XChange(x)}
if cType=='N'
:nMaxLength:=nLen
:nAlignment:=taRIGHT
elseif cType=='C'
:nMaxLength:=len(cValue)
:nAlignment:=taLEFT
endif
if !empty(cPicture)
:cPicture:=cPicture
endif
:Create()
END
return oObj
static func XChange(oCtl)
local xRet
xRet:=eval(oCtl:bBlock, oCtl:Value)
return xRet
edit1.ch
--------
// @..GET
#command @ <row>,<col> GET <var> ;
[PICTURE <pic>] ;
;
=> CFEdit(oFrm, <row>, <col>, {|_1| if(pcount()>0,<var>:=_1,<var>)}, <pic>)
data edit program
------------------
#include "edit1.ch"
func DataEdit()
local oFrm, n1
n1:=0
oFrm:=TForm():New(Application)
@1,1 get n1 picture '999'
.....
if oFrm:ShowModal()
...
endif
return
Regards, Oleg
Mike Evans
Mensajes: 7
Registrado: Vie May 30, 2008 3:51 pm

TMaskedit and array values.

Mensaje por Mike Evans »

On Wed, 11 Jun 2008 15:21:56 +0500, Oleg wrote:
> Mike,
>
>> What we need is a datalink property in each TMaskedit. This property must
>> take also defines Datalink := {|xValue| If( xValue == NIL, APG1_0304,
>> APG1_0304 := xValue) }
>
> maybe you need something like this (a piece of code from my programs)
>
>
> edit1.prg
> ---------
>
> CLASS TEDIT FROM XEDIT
> PUBLISHED:
> DATA bBlock
> ENDCLASS
>
> func CFEdit(oForm, nRow, nCol, bBlock, cPicture)
> local oObj, aRect, cValue, nLen, cType, oObjDop
> cValue:=eval(bBlock)
> cType:=valtype(cValue)
> if cPicture<>NIL
> nLen:=len(transform(cValue, cPicture))
> else
> if cType=='C'
> nLen:=len(cValue)
> elseif cType=='N'
> nLen:=len(str(cValue))
> elseif cType=='D'
> nLen:=9
> endif
> endif
> oObj:=TMaskEdit():New( oForm )
> WITH OBJECT oObj
> :SetBounds(nCol, nRow, CW_EDIT_WIDTH*nLen, CW_EDIT_HEIGHT)
> :bBlock:=bBlock
> :Value:=cValue
> :OnChange:={|x| XChange(x)}
> if cType=='N'
> :nMaxLength:=nLen
> :nAlignment:=taRIGHT
> elseif cType=='C'
> :nMaxLength:=len(cValue)
> :nAlignment:=taLEFT
> endif
> if !empty(cPicture)
> :cPicture:=cPicture
> endif
> :Create()
> END
> return oObj
>
> static func XChange(oCtl)
> local xRet
> xRet:=eval(oCtl:bBlock, oCtl:Value)
> return xRet
>
> edit1.ch
> --------
> // @..GET
> #command @ <row>,<col> GET <var> ;
> [PICTURE <pic>] ;
> ;
> => CFEdit(oFrm, <row>, <col>, {|_1| if(pcount()>0,<var>:=_1,<var>)}, <pic>)
>
>
> data edit program
> ------------------
> #include "edit1.ch"
>
> func DataEdit()
> local oFrm, n1
>
> n1:=0
> oFrm:=TForm():New(Application)
> @1,1 get n1 picture '999'
> ....
> if oFrm:ShowModal()
> ...
> endif
> return
>
> Regards, Oleg
Hi Oleg,
Thank you very much, but i need to stick with the form designer (I need to
position each tmaskedit in specific position in the background bitmap). So
is it possible the bBlock to be accessible throught the IDE property
window?
Thanks in advance
Mike Evans
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

TMaskedit and array values.

Mensaje por jfgimenez »

Mike,
> Thank you very much, but i need to stick with the form designer (I need to
> position each tmaskedit in specific position in the background bitmap). So
> is it possible the bBlock to be accessible throught the IDE property
> window?
You may use the property 'Cargo' to store what you need at design time, and
use it at runtime to determine what element of the array has to manage each
edit. Moreover, you may use the form's OnInitialize event to create/assign a
codeblock or a get/set routine based on the edit's cargo property.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Responder