Groups > dBase > dBase Internet > Re: Error with loadFieldsFromArray method. HELP




Error with loadFieldsFromArray method. HELP

Error with loadFieldsFromArray method. HELP
Thu, 13 Mar 2008 03:24:22 -050
I am getting an error in my web app that makes reference to the webclass.cc when
I use the loadFieldsFromArray method. I need to add rows to a table and they
could be in different numbers depending on the previous app results. I'm using
the method to add a row in the first instruction, (working fine) and then there
is a loop that takes the value/pairs from the previous app and the it attempts
to add the each row in tha table (there is where it cracks) Here is the extract
of the app :

       * Save in cotizaciones1.dbf

         oCGI.loadFieldsFromArray(COTIZACIONES1.rowset.fields, true)

         * guarda en pliegos.dbf

         cpliegos16=VAL(oCGI["pliegos16"])

         IF cpliegos16>0

            FOR K=1 TO cpliegos16

                varpap="tipap16_"+LTRIM(STR(K))
                vartft="tinfte16_"+LTRIM(STR(K))
                vartvt="tinvta16_"+LTRIM(STR(K))
                varbmfte="bmfte16_"+LTRIM(STR(K))
                varbmftereg="bmftereg16_"+LTRIM(STR(K))
                varbmvta="bmvta16_"+LTRIM(STR(K))
                varbmvtareg="bmvtareg16_"+LTRIM(STR(K))
                vartiplam="tiplam16_"+LTRIM(STR(K))

                varplianc="plianc16_"+LTRIM(STR(K))
                varplilar="plilar16_"+LTRIM(STR(K))
                varplinum="plinum16_"+LTRIM(STR(K))
                varpapanc="papanc16_"+LTRIM(STR(K))
                varpaplar="paplar16_"+LTRIM(STR(K))
                varcanpaq="canpaq16_"+LTRIM(STR(K))
                varcanpli="canpli16_"+LTRIM(STR(K))
                varentranpli1="entranpli116_"+LTRIM(STR(K))
                varentranpli2="entranpli216_"+LTRIM(STR(K))
                varentranplitot="entranplitot16_"+LTRIM(STR(K))
                varmerma1="merma116_"+LTRIM(STR(K))
                varmerma2="merma216_"+LTRIM(STR(K))
                varcostpap="costpap16_"+LTRIM(STR(K))
                varentranmaq1="entranmaq116_"+LTRIM(STR(K))
                varentranmaq2="entranmaq216_"+LTRIM(STR(K))
                varentranmaqtot="entranmaqtot16_"+LTRIM(STR(K))
                varmaquina="maquina16_"+LTRIM(STR(K))
                varprecio2="precio216_"+LTRIM(STR(K))
                varparreglo="parreglo16_"+LTRIM(STR(K))
                varplamina="plamina16_"+LTRIM(STR(K))
                varttotal="ttotal16_"+LTRIM(STR(K))

             	 oCGI["tipo_pliego"]="16"
                oCGI["tipap"]=oCGI["&varpap"]
                oCGI["tinfte"]=oCGI["&vartft"]
                oCGI["tinvta"]=oCGI["&vartvt"]
                oCGI["bmfte"]=oCGI["&varbmfte"]
                oCGI["bmftereg"]=oCGI["&varbmftereg"]
                oCGI["bmvta"]=oCGI["&varbmvta"]
                oCGI["bmvtareg"]=oCGI["&varbmvtareg"]
                oCGI["tiplam"]=oCGI["&vartiplam"]
                oCGI["plianc"]=oCGI["&varplianc"]
                oCGI["plilar"]=oCGI["&varplilar"]
                oCGI["plinum"]=oCGI["&varplinum"]
                oCGI["papanc"]=oCGI["&varpapanc"]
                oCGI["paplar"]=oCGI["&varpaplar"]
                oCGI["canpaq"]=oCGI["&varcanpaq"]
                oCGI["canpli"]=oCGI["&varcanpli"]
               
oCGI["entranpli1"]=oCGI["&varentranpli1"]
               
oCGI["entranpli2"]=oCGI["&varentranpli2"]
               
oCGI["entranplitot"]=oCGI["&varentranplitot"]
                oCGI["merma1"]=oCGI["&varmerma1"]
                oCGI["merma2"]=oCGI["&varmerma2"]
                oCGI["costpap"]=oCGI["&varcostpap"]
               
oCGI["entranmaq1"]=oCGI["&varentranmaq1"]
               
oCGI["entranmaq2"]=oCGI["&varentranmaq2"]
               
oCGI["entranmaqtot"]=oCGI["&varentranmaqtot"]
                oCGI["maquina"]=oCGI["&varmaquina"]
                oCGI["precio2"]=oCGI["&varprecio2"]
                oCGI["parreglo"]=oCGI["&varparreglo"]
                oCGI["plamina"]=oCGI["&varplamina"]
                oCGI["ttotal"]=oCGI["&varttotal"]

                oCGI.loadFieldsFromArray(PLIEGOS.rowset.fields, true)
--->HERE IS WHERE IT CRACKS. NOT EVEN ADD ONE ROW)

            NEXT K

         ENDIF

The reference in the webclass where the erros is is the following : 

Function loadFieldsFromArray(rowsetFields,bAppend)

      bAppend = iif(empty(bAppend),false,true)

      rf = rowsetFields  // Create private instance of param

      ////// If bAppend, make new row
      if bAppend
         rf.parent.beginAppend()
      endif

      ////// Establish first key
      cKey = this.firstKey

      ///// Traverse the array
      for n = 1 to this.count()

         if type('rf[cKey]') = 'O'  // if field exists 
            
            with (rf[ckey])         // with (field)

               if type  = "LOGICAL"   // convert text to type and
store

                  value = iif(upper(this[cKey]) ='TRUE' or ;
                           upper(this[cKey]) = 'Y',true,false)
 
               elseif type = "NUMERIC" or ;
                  type = "INTEGER" or ;
                  type = "DOUBLE" or ;
                  type = "FLOAT" or ;
                  type = "LONG"

                  value = val(this[cKey]) --> THIS IS THE LINE WHERE THED
ERROR OCCURS.
 
               elseif type = "DATE"

                  value = ctod(this[cKey])
 
               elseif type = "AUTOINC" or ;
                      type = 'TIMESTAMP' or ;
                      type = 'BINARY' or ;
                      type = 'OLE'

                    // do nothing!! Autoincrement is automatic
                    // and the others not supported in HTML

The error is not clear because it attempts to make a Spanish translation (I
think so ¿?). Anyway, the error is :

 An error ocurred on the server 
    
  File: c:\apache\www\impressive\cgibin\Webclass.cc 
  Line No:759 
  Database Engine Error: Error de traducción. Traducción NO REALIZADA. 
    
  Contact the WebMaster 


Any help will be appreciated.

Thank you

Horacio Echeverria

Post Reply
Re: Error with loadFieldsFromArray method. HELP
Thu, 13 Mar 2008 10:42:14 -050
Why are you running a macro to create each variable?
>                varpap="tipap16_"+LTRIM(STR(K))

>                oCGI["tipap"]=oCGI["&varpap"]
Usually these two lines would be written as
                varpap = "tipap16_"+LTRIM(STR(K))

                oCGI["tipap"] = varpap

Where is "K" comming from?

Typically when you use the webClass.cc you are either streaming out a 
response page from the server or you are reading a .html page the user has 
submitted to the server.

From your description "loadFieldsFromArray" you must be reading an
.html 
page.  In which case the oCGI array would have been created when you used 
the

     Set proc to WebClass.cc additive
     oCGI = new CGISession ()

If that is so then you already have some data in the oCGI array.  If you did 
not do this then maybe you don't have the oCGI array created.

If you are creating additional oCGI elements based on "K", then you do
not 
have those in the the oCGI array because you did not store them in there in 
first place.
To do that you would have to write your lines as follows:

 oCGI["tipap"]="tipap16_"+LTRIM(STR(K)) //just one line not
two.

Can you translate the error message to English?

Usually this type of problem comes up because one of your fields are 
defaulting to the wrong type.

Try cutting down on the fields that are processed.  Eventually you will hit 
the one that is creating the problem.

Claus


"Horacio Echeverria" <horacioeg@yahoo.com> wrote in message 
news:t55JkOOhIHA.1864@news-server...
>I am getting an error in my web app that makes reference to the webclass.cc

>when I use the loadFieldsFromArray method. I need to add rows to a table 
>and they could be in different numbers depending on the previous app 
>results. I'm using the method to add a row in the first instruction, 
>(working fine) and then there is a loop that takes the value/pairs from the

>previous app and the it attempts to add the each row in tha table (there is

>where it cracks) Here is the extract of the app :
>
>       * Save in cotizaciones1.dbf
>
>         oCGI.loadFieldsFromArray(COTIZACIONES1.rowset.fields, true)
>
>         * guarda en pliegos.dbf
>
>         cpliegos16=VAL(oCGI["pliegos16"])
>
>         IF cpliegos16>0
>
>            FOR K=1 TO cpliegos16
>
>                varpap="tipap16_"+LTRIM(STR(K))
>                vartft="tinfte16_"+LTRIM(STR(K))
>                vartvt="tinvta16_"+LTRIM(STR(K))
>                varbmfte="bmfte16_"+LTRIM(STR(K))
>                varbmftereg="bmftereg16_"+LTRIM(STR(K))
>                varbmvta="bmvta16_"+LTRIM(STR(K))
>                varbmvtareg="bmvtareg16_"+LTRIM(STR(K))
>                vartiplam="tiplam16_"+LTRIM(STR(K))
>
>                varplianc="plianc16_"+LTRIM(STR(K))
>                varplilar="plilar16_"+LTRIM(STR(K))
>                varplinum="plinum16_"+LTRIM(STR(K))
>                varpapanc="papanc16_"+LTRIM(STR(K))
>                varpaplar="paplar16_"+LTRIM(STR(K))
>                varcanpaq="canpaq16_"+LTRIM(STR(K))
>                varcanpli="canpli16_"+LTRIM(STR(K))
>                varentranpli1="entranpli116_"+LTRIM(STR(K))
>                varentranpli2="entranpli216_"+LTRIM(STR(K))
>                varentranplitot="entranplitot16_"+LTRIM(STR(K))
>                varmerma1="merma116_"+LTRIM(STR(K))
>                varmerma2="merma216_"+LTRIM(STR(K))
>                varcostpap="costpap16_"+LTRIM(STR(K))
>                varentranmaq1="entranmaq116_"+LTRIM(STR(K))
>                varentranmaq2="entranmaq216_"+LTRIM(STR(K))
>                varentranmaqtot="entranmaqtot16_"+LTRIM(STR(K))
>                varmaquina="maquina16_"+LTRIM(STR(K))
>                varprecio2="precio216_"+LTRIM(STR(K))
>                varparreglo="parreglo16_"+LTRIM(STR(K))
>                varplamina="plamina16_"+LTRIM(STR(K))
>                varttotal="ttotal16_"+LTRIM(STR(K))
>
>             oCGI["tipo_pliego"]="16"
>                oCGI["tipap"]=oCGI["&varpap"]
>                oCGI["tinfte"]=oCGI["&vartft"]
>                oCGI["tinvta"]=oCGI["&vartvt"]
>                oCGI["bmfte"]=oCGI["&varbmfte"]
>               
oCGI["bmftereg"]=oCGI["&varbmftereg"]
>                oCGI["bmvta"]=oCGI["&varbmvta"]
>               
oCGI["bmvtareg"]=oCGI["&varbmvtareg"]
>                oCGI["tiplam"]=oCGI["&vartiplam"]
>                oCGI["plianc"]=oCGI["&varplianc"]
>                oCGI["plilar"]=oCGI["&varplilar"]
>                oCGI["plinum"]=oCGI["&varplinum"]
>                oCGI["papanc"]=oCGI["&varpapanc"]
>                oCGI["paplar"]=oCGI["&varpaplar"]
>                oCGI["canpaq"]=oCGI["&varcanpaq"]
>                oCGI["canpli"]=oCGI["&varcanpli"]
>               
oCGI["entranpli1"]=oCGI["&varentranpli1"]
>               
oCGI["entranpli2"]=oCGI["&varentranpli2"]
>               
oCGI["entranplitot"]=oCGI["&varentranplitot"]
>                oCGI["merma1"]=oCGI["&varmerma1"]
>                oCGI["merma2"]=oCGI["&varmerma2"]
>                oCGI["costpap"]=oCGI["&varcostpap"]
>               
oCGI["entranmaq1"]=oCGI["&varentranmaq1"]
>               
oCGI["entranmaq2"]=oCGI["&varentranmaq2"]
>               
oCGI["entranmaqtot"]=oCGI["&varentranmaqtot"]
>                oCGI["maquina"]=oCGI["&varmaquina"]
>                oCGI["precio2"]=oCGI["&varprecio2"]
>               
oCGI["parreglo"]=oCGI["&varparreglo"]
>                oCGI["plamina"]=oCGI["&varplamina"]
>                oCGI["ttotal"]=oCGI["&varttotal"]
>
>                oCGI.loadFieldsFromArray(PLIEGOS.rowset.fields, 
> true) --->HERE IS WHERE IT CRACKS. NOT EVEN ADD ONE ROW)
>
>            NEXT K
>
>         ENDIF
>
> The reference in the webclass where the erros is is the following :
>
> Function loadFieldsFromArray(rowsetFields,bAppend)
>
>      bAppend = iif(empty(bAppend),false,true)
>
>      rf = rowsetFields  // Create private instance of param
>
>      ////// If bAppend, make new row
>      if bAppend
>         rf.parent.beginAppend()
>      endif
>
>      ////// Establish first key
>      cKey = this.firstKey
>
>      ///// Traverse the array
>      for n = 1 to this.count()
>
>         if type('rf[cKey]') = 'O'  // if field exists
>
>            with (rf[ckey])         // with (field)
>
>               if type  = "LOGICAL"   // convert text to type and
store
>
>                  value = iif(upper(this[cKey]) ='TRUE' or ;
>                           upper(this[cKey]) = 'Y',true,false)
>
>               elseif type = "NUMERIC" or ;
>                  type = "INTEGER" or ;
>                  type = "DOUBLE" or ;
>                  type = "FLOAT" or ;
>                  type = "LONG"
>
>                  value = val(this[cKey]) --> THIS IS THE LINE WHERE THED

> ERROR OCCURS.
>
>               elseif type = "DATE"
>
>                  value = ctod(this[cKey])
>
>               elseif type = "AUTOINC" or ;
>                      type = 'TIMESTAMP' or ;
>                      type = 'BINARY' or ;
>                      type = 'OLE'
>
>                    // do nothing!! Autoincrement is automatic
>                    // and the others not supported in HTML
>
> The error is not clear because it attempts to make a Spanish translation 
> (I think so ¿?). Anyway, the error is :
>
> An error ocurred on the server
>
>  File: c:\apache\www\impressive\cgibin\Webclass.cc
>  Line No:759
>  Database Engine Error: Error de traducción. Traducción NO REALIZADA.
>
>  Contact the WebMaster
>
>
> Any help will be appreciated.
>
> Thank you
>
> Horacio Echeverria
>
> 

Post Reply
Re: Error with loadFieldsFromArray method. HELP
Thu, 13 Mar 2008 11:57:12 -050
Claus,

Thank you for your answer. Following your advice of cutting the fiields one by
one, I solved the problem that was in the table itself. The first field had a 1
character space rather than 2, so the "16" wasn´t entering in to that
field. 
The reason I'm using a macro, is that the html that sends the data into the
script, can send a different number of value/pair variables, each time, so that
solves the problem. Sometimes it can send 1 set of variables and sometimes 40,
50 or whatever the previous script generates.
Thanks again
Horacio


Claus Mygind Wrote:

> Why are you running a macro to create each variable?
> >                varpap="tipap16_"+LTRIM(STR(K))
> 
> >                oCGI["tipap"]=oCGI["&varpap"]
> Usually these two lines would be written as
>                 varpap = "tipap16_"+LTRIM(STR(K))
> 
>                 oCGI["tipap"] = varpap
> 
> Where is "K" comming from?
> 
> Typically when you use the webClass.cc you are either streaming out a 
> response page from the server or you are reading a .html page the user has

> submitted to the server.
> 
> From your description "loadFieldsFromArray" you must be reading
an .html 
> page.  In which case the oCGI array would have been created when you used 
> the
> 
>      Set proc to WebClass.cc additive
>      oCGI = new CGISession ()
> 
> If that is so then you already have some data in the oCGI array.  If you
did 
> not do this then maybe you don't have the oCGI array created.
> 
> If you are creating additional oCGI elements based on "K", then
you do not 
> have those in the the oCGI array because you did not store them in there in

> first place.
> To do that you would have to write your lines as follows:
> 
>  oCGI["tipap"]="tipap16_"+LTRIM(STR(K)) //just one line
not two.
> 
> Can you translate the error message to English?
> 
> Usually this type of problem comes up because one of your fields are 
> defaulting to the wrong type.
> 
> Try cutting down on the fields that are processed.  Eventually you will hit

> the one that is creating the problem.
> 
> Claus
> 
> 
> "Horacio Echeverria" <horacioeg@yahoo.com> wrote in message

> news:t55JkOOhIHA.1864@news-server...
> >I am getting an error in my web app that makes reference to the
webclass.cc 
> >when I use the loadFieldsFromArray method. I need to add rows to a
table 
> >and they could be in different numbers depending on the previous app 
> >results. I'm using the method to add a row in the first instruction, 
> >(working fine) and then there is a loop that takes the value/pairs from
the 
> >previous app and the it attempts to add the each row in tha table
(there is 
> >where it cracks) Here is the extract of the app :
> >
> >       * Save in cotizaciones1.dbf
> >
> >         oCGI.loadFieldsFromArray(COTIZACIONES1.rowset.fields, true)
> >
> >         * guarda en pliegos.dbf
> >
> >         cpliegos16=VAL(oCGI["pliegos16"])
> >
> >         IF cpliegos16>0
> >
> >            FOR K=1 TO cpliegos16
> >
> >                varpap="tipap16_"+LTRIM(STR(K))
> >                vartft="tinfte16_"+LTRIM(STR(K))
> >                vartvt="tinvta16_"+LTRIM(STR(K))
> >                varbmfte="bmfte16_"+LTRIM(STR(K))
> >                varbmftereg="bmftereg16_"+LTRIM(STR(K))
> >                varbmvta="bmvta16_"+LTRIM(STR(K))
> >                varbmvtareg="bmvtareg16_"+LTRIM(STR(K))
> >                vartiplam="tiplam16_"+LTRIM(STR(K))
> >
> >                varplianc="plianc16_"+LTRIM(STR(K))
> >                varplilar="plilar16_"+LTRIM(STR(K))
> >                varplinum="plinum16_"+LTRIM(STR(K))
> >                varpapanc="papanc16_"+LTRIM(STR(K))
> >                varpaplar="paplar16_"+LTRIM(STR(K))
> >                varcanpaq="canpaq16_"+LTRIM(STR(K))
> >                varcanpli="canpli16_"+LTRIM(STR(K))
> >                varentranpli1="entranpli116_"+LTRIM(STR(K))
> >                varentranpli2="entranpli216_"+LTRIM(STR(K))
> >               
varentranplitot="entranplitot16_"+LTRIM(STR(K))
> >                varmerma1="merma116_"+LTRIM(STR(K))
> >                varmerma2="merma216_"+LTRIM(STR(K))
> >                varcostpap="costpap16_"+LTRIM(STR(K))
> >                varentranmaq1="entranmaq116_"+LTRIM(STR(K))
> >                varentranmaq2="entranmaq216_"+LTRIM(STR(K))
> >               
varentranmaqtot="entranmaqtot16_"+LTRIM(STR(K))
> >                varmaquina="maquina16_"+LTRIM(STR(K))
> >                varprecio2="precio216_"+LTRIM(STR(K))
> >                varparreglo="parreglo16_"+LTRIM(STR(K))
> >                varplamina="plamina16_"+LTRIM(STR(K))
> >                varttotal="ttotal16_"+LTRIM(STR(K))
> >
> >             oCGI["tipo_pliego"]="16"
> >                oCGI["tipap"]=oCGI["&varpap"]
> >                oCGI["tinfte"]=oCGI["&vartft"]
> >                oCGI["tinvta"]=oCGI["&vartvt"]
> >               
oCGI["bmfte"]=oCGI["&varbmfte"]
> >               
oCGI["bmftereg"]=oCGI["&varbmftereg"]
> >               
oCGI["bmvta"]=oCGI["&varbmvta"]
> >               
oCGI["bmvtareg"]=oCGI["&varbmvtareg"]
> >               
oCGI["tiplam"]=oCGI["&vartiplam"]
> >               
oCGI["plianc"]=oCGI["&varplianc"]
> >               
oCGI["plilar"]=oCGI["&varplilar"]
> >               
oCGI["plinum"]=oCGI["&varplinum"]
> >               
oCGI["papanc"]=oCGI["&varpapanc"]
> >               
oCGI["paplar"]=oCGI["&varpaplar"]
> >               
oCGI["canpaq"]=oCGI["&varcanpaq"]
> >               
oCGI["canpli"]=oCGI["&varcanpli"]
> >               
oCGI["entranpli1"]=oCGI["&varentranpli1"]
> >               
oCGI["entranpli2"]=oCGI["&varentranpli2"]
> >               
oCGI["entranplitot"]=oCGI["&varentranplitot"]
> >               
oCGI["merma1"]=oCGI["&varmerma1"]
> >               
oCGI["merma2"]=oCGI["&varmerma2"]
> >               
oCGI["costpap"]=oCGI["&varcostpap"]
> >               
oCGI["entranmaq1"]=oCGI["&varentranmaq1"]
> >               
oCGI["entranmaq2"]=oCGI["&varentranmaq2"]
> >               
oCGI["entranmaqtot"]=oCGI["&varentranmaqtot"]
> >               
oCGI["maquina"]=oCGI["&varmaquina"]
> >               
oCGI["precio2"]=oCGI["&varprecio2"]
> >               
oCGI["parreglo"]=oCGI["&varparreglo"]
> >               
oCGI["plamina"]=oCGI["&varplamina"]
> >               
oCGI["ttotal"]=oCGI["&varttotal"]
> >
> >                oCGI.loadFieldsFromArray(PLIEGOS.rowset.fields, 
> > true) --->HERE IS WHERE IT CRACKS. NOT EVEN ADD ONE ROW)
> >
> >            NEXT K
> >
> >         ENDIF
> >
> > The reference in the webclass where the erros is is the following :
> >
> > Function loadFieldsFromArray(rowsetFields,bAppend)
> >
> >      bAppend = iif(empty(bAppend),false,true)
> >
> >      rf = rowsetFields  // Create private instance of param
> >
> >      ////// If bAppend, make new row
> >      if bAppend
> >         rf.parent.beginAppend()
> >      endif
> >
> >      ////// Establish first key
> >      cKey = this.firstKey
> >
> >      ///// Traverse the array
> >      for n = 1 to this.count()
> >
> >         if type('rf[cKey]') = 'O'  // if field exists
> >
> >            with (rf[ckey])         // with (field)
> >
> >               if type  = "LOGICAL"   // convert text to type
and store
> >
> >                  value = iif(upper(this[cKey]) ='TRUE' or ;
> >                           upper(this[cKey]) = 'Y',true,false)
> >
> >               elseif type = "NUMERIC" or ;
> >                  type = "INTEGER" or ;
> >                  type = "DOUBLE" or ;
> >                  type = "FLOAT" or ;
> >                  type = "LONG"
> >
> >                  value = val(this[cKey]) --> THIS IS THE LINE WHERE
THED 
> > ERROR OCCURS.
> >
> >               elseif type = "DATE"
> >
> >                  value = ctod(this[cKey])
> >
> >               elseif type = "AUTOINC" or ;
> >                      type = 'TIMESTAMP' or ;
> >                      type = 'BINARY' or ;
> >                      type = 'OLE'
> >
> >                    // do nothing!! Autoincrement is automatic
> >                    // and the others not supported in HTML
> >
> > The error is not clear because it attempts to make a Spanish
translation 
> > (I think so ¿?). Anyway, the error is :
> >
> > An error ocurred on the server
> >
> >  File: c:\apache\www\impressive\cgibin\Webclass.cc
> >  Line No:759
> >  Database Engine Error: Error de traducción. Traducción NO REALIZADA.
> >
> >  Contact the WebMaster
> >
> >
> > Any help will be appreciated.
> >
> > Thank you
> >
> > Horacio Echeverria
> >
> > 
> 
> 
Post Reply
Re: Error with loadFieldsFromArray method. HELP
Thu, 13 Mar 2008 11:57:55 -050
Great! I am glad it worked out for you.

But the "loadFieldsFromArray" is setup to handle a variable number of
oCGI 
elements.  And while there may be oCGI elements that do not match the name 
of the fields in your .dbf table, they will automatically be ignored.  If 
the data fields (elements) on your .html screen match the names of the .dbf 
fields both in name and case, then the process would be automatic. ie: 
oCGI['Name'] = t1.Name

You should only have to manipulate the data in a variable if you want to 
format the data or some such thing.

Well if it works for you that good and nothing further needs to be said.
Claus

"Horacio Echeverria" <horacioeg@yahoo.com> wrote in message 
news:g5bhItShIHA.1564@news-server...
> Claus,
>
> Thank you for your answer. Following your advice of cutting the fiields 
> one by one, I solved the problem that was in the table itself. The first 
> field had a 1 character space rather than 2, so the "16" wasn´t
entering 
> in to that field.
> The reason I'm using a macro, is that the html that sends the data into 
> the script, can send a different number of value/pair variables, each 
> time, so that solves the problem. Sometimes it can send 1 set of variables

> and sometimes 40, 50 or whatever the previous script generates.
> Thanks again
> Horacio
>
>
> Claus Mygind Wrote:
>
>> Why are you running a macro to create each variable?
>> >                varpap="tipap16_"+LTRIM(STR(K))
>>
>> >               
oCGI["tipap"]=oCGI["&varpap"]
>> Usually these two lines would be written as
>>                 varpap = "tipap16_"+LTRIM(STR(K))
>>
>>                 oCGI["tipap"] = varpap
>>
>> Where is "K" comming from?
>>
>> Typically when you use the webClass.cc you are either streaming out a
>> response page from the server or you are reading a .html page the user

>> has
>> submitted to the server.
>>
>> From your description "loadFieldsFromArray" you must be
reading an .html
>> page.  In which case the oCGI array would have been created when you
used
>> the
>>
>>      Set proc to WebClass.cc additive
>>      oCGI = new CGISession ()
>>
>> If that is so then you already have some data in the oCGI array.  If
you 
>> did
>> not do this then maybe you don't have the oCGI array created.
>>
>> If you are creating additional oCGI elements based on "K",
then you do 
>> not
>> have those in the the oCGI array because you did not store them in
there 
>> in
>> first place.
>> To do that you would have to write your lines as follows:
>>
>>  oCGI["tipap"]="tipap16_"+LTRIM(STR(K)) //just one
line not two.
>>
>> Can you translate the error message to English?
>>
>> Usually this type of problem comes up because one of your fields are
>> defaulting to the wrong type.
>>
>> Try cutting down on the fields that are processed.  Eventually you will

>> hit
>> the one that is creating the problem.
>>
>> Claus
>>
>>
>> "Horacio Echeverria" <horacioeg@yahoo.com> wrote in
message
>> news:t55JkOOhIHA.1864@news-server...
>> >I am getting an error in my web app that makes reference to the 
>> >webclass.cc
>> >when I use the loadFieldsFromArray method. I need to add rows to a
table
>> >and they could be in different numbers depending on the previous
app
>> >results. I'm using the method to add a row in the first
instruction,
>> >(working fine) and then there is a loop that takes the value/pairs
from 
>> >the
>> >previous app and the it attempts to add the each row in tha table
(there 
>> >is
>> >where it cracks) Here is the extract of the app :
>> >
>> >       * Save in cotizaciones1.dbf
>> >
>> >         oCGI.loadFieldsFromArray(COTIZACIONES1.rowset.fields,
true)
>> >
>> >         * guarda en pliegos.dbf
>> >
>> >         cpliegos16=VAL(oCGI["pliegos16"])
>> >
>> >         IF cpliegos16>0
>> >
>> >            FOR K=1 TO cpliegos16
>> >
>> >                varpap="tipap16_"+LTRIM(STR(K))
>> >                vartft="tinfte16_"+LTRIM(STR(K))
>> >                vartvt="tinvta16_"+LTRIM(STR(K))
>> >                varbmfte="bmfte16_"+LTRIM(STR(K))
>> >                varbmftereg="bmftereg16_"+LTRIM(STR(K))
>> >                varbmvta="bmvta16_"+LTRIM(STR(K))
>> >                varbmvtareg="bmvtareg16_"+LTRIM(STR(K))
>> >                vartiplam="tiplam16_"+LTRIM(STR(K))
>> >
>> >                varplianc="plianc16_"+LTRIM(STR(K))
>> >                varplilar="plilar16_"+LTRIM(STR(K))
>> >                varplinum="plinum16_"+LTRIM(STR(K))
>> >                varpapanc="papanc16_"+LTRIM(STR(K))
>> >                varpaplar="paplar16_"+LTRIM(STR(K))
>> >                varcanpaq="canpaq16_"+LTRIM(STR(K))
>> >                varcanpli="canpli16_"+LTRIM(STR(K))
>> >               
varentranpli1="entranpli116_"+LTRIM(STR(K))
>> >               
varentranpli2="entranpli216_"+LTRIM(STR(K))
>> >               
varentranplitot="entranplitot16_"+LTRIM(STR(K))
>> >                varmerma1="merma116_"+LTRIM(STR(K))
>> >                varmerma2="merma216_"+LTRIM(STR(K))
>> >                varcostpap="costpap16_"+LTRIM(STR(K))
>> >               
varentranmaq1="entranmaq116_"+LTRIM(STR(K))
>> >               
varentranmaq2="entranmaq216_"+LTRIM(STR(K))
>> >               
varentranmaqtot="entranmaqtot16_"+LTRIM(STR(K))
>> >                varmaquina="maquina16_"+LTRIM(STR(K))
>> >                varprecio2="precio216_"+LTRIM(STR(K))
>> >                varparreglo="parreglo16_"+LTRIM(STR(K))
>> >                varplamina="plamina16_"+LTRIM(STR(K))
>> >                varttotal="ttotal16_"+LTRIM(STR(K))
>> >
>> >             oCGI["tipo_pliego"]="16"
>> >               
oCGI["tipap"]=oCGI["&varpap"]
>> >               
oCGI["tinfte"]=oCGI["&vartft"]
>> >               
oCGI["tinvta"]=oCGI["&vartvt"]
>> >               
oCGI["bmfte"]=oCGI["&varbmfte"]
>> >               
oCGI["bmftereg"]=oCGI["&varbmftereg"]
>> >               
oCGI["bmvta"]=oCGI["&varbmvta"]
>> >               
oCGI["bmvtareg"]=oCGI["&varbmvtareg"]
>> >               
oCGI["tiplam"]=oCGI["&vartiplam"]
>> >               
oCGI["plianc"]=oCGI["&varplianc"]
>> >               
oCGI["plilar"]=oCGI["&varplilar"]
>> >               
oCGI["plinum"]=oCGI["&varplinum"]
>> >               
oCGI["papanc"]=oCGI["&varpapanc"]
>> >               
oCGI["paplar"]=oCGI["&varpaplar"]
>> >               
oCGI["canpaq"]=oCGI["&varcanpaq"]
>> >               
oCGI["canpli"]=oCGI["&varcanpli"]
>> >               
oCGI["entranpli1"]=oCGI["&varentranpli1"]
>> >               
oCGI["entranpli2"]=oCGI["&varentranpli2"]
>> >               
oCGI["entranplitot"]=oCGI["&varentranplitot"]
>> >               
oCGI["merma1"]=oCGI["&varmerma1"]
>> >               
oCGI["merma2"]=oCGI["&varmerma2"]
>> >               
oCGI["costpap"]=oCGI["&varcostpap"]
>> >               
oCGI["entranmaq1"]=oCGI["&varentranmaq1"]
>> >               
oCGI["entranmaq2"]=oCGI["&varentranmaq2"]
>> >               
oCGI["entranmaqtot"]=oCGI["&varentranmaqtot"]
>> >               
oCGI["maquina"]=oCGI["&varmaquina"]
>> >               
oCGI["precio2"]=oCGI["&varprecio2"]
>> >               
oCGI["parreglo"]=oCGI["&varparreglo"]
>> >               
oCGI["plamina"]=oCGI["&varplamina"]
>> >               
oCGI["ttotal"]=oCGI["&varttotal"]
>> >
>> >                oCGI.loadFieldsFromArray(PLIEGOS.rowset.fields,
>> > true) --->HERE IS WHERE IT CRACKS. NOT EVEN ADD ONE ROW)
>> >
>> >            NEXT K
>> >
>> >         ENDIF
>> >
>> > The reference in the webclass where the erros is is the following
:
>> >
>> > Function loadFieldsFromArray(rowsetFields,bAppend)
>> >
>> >      bAppend = iif(empty(bAppend),false,true)
>> >
>> >      rf = rowsetFields  // Create private instance of param
>> >
>> >      ////// If bAppend, make new row
>> >      if bAppend
>> >         rf.parent.beginAppend()
>> >      endif
>> >
>> >      ////// Establish first key
>> >      cKey = this.firstKey
>> >
>> >      ///// Traverse the array
>> >      for n = 1 to this.count()
>> >
>> >         if type('rf[cKey]') = 'O'  // if field exists
>> >
>> >            with (rf[ckey])         // with (field)
>> >
>> >               if type  = "LOGICAL"   // convert text to
type and store
>> >
>> >                  value = iif(upper(this[cKey]) ='TRUE' or ;
>> >                           upper(this[cKey]) = 'Y',true,false)
>> >
>> >               elseif type = "NUMERIC" or ;
>> >                  type = "INTEGER" or ;
>> >                  type = "DOUBLE" or ;
>> >                  type = "FLOAT" or ;
>> >                  type = "LONG"
>> >
>> >                  value = val(this[cKey]) --> THIS IS THE LINE
WHERE 
>> > THED
>> > ERROR OCCURS.
>> >
>> >               elseif type = "DATE"
>> >
>> >                  value = ctod(this[cKey])
>> >
>> >               elseif type = "AUTOINC" or ;
>> >                      type = 'TIMESTAMP' or ;
>> >                      type = 'BINARY' or ;
>> >                      type = 'OLE'
>> >
>> >                    // do nothing!! Autoincrement is automatic
>> >                    // and the others not supported in HTML
>> >
>> > The error is not clear because it attempts to make a Spanish 
>> > translation
>> > (I think so ¿?). Anyway, the error is :
>> >
>> > An error ocurred on the server
>> >
>> >  File: c:\apache\www\impressive\cgibin\Webclass.cc
>> >  Line No:759
>> >  Database Engine Error: Error de traducción. Traducción NO
REALIZADA.
>> >
>> >  Contact the WebMaster
>> >
>> >
>> > Any help will be appreciated.
>> >
>> > Thank you
>> >
>> > Horacio Echeverria
>> >
>> >
>>
>>
> 

Post Reply
Re: Error with loadFieldsFromArray method. HELP
Thu, 13 Mar 2008 12:36:09 -050
Ok I get it.  I do that myself many times.

Claus

"Horacio Echeverria" <horacioeg@yahoo.com> wrote in message 
news:CCZzTFThIHA.760@news-server...
> Well, the reason that I'm doing this is that in one shot, the program has 
> to add many rows into the table at once. Lets say that the table has 4 
> fields (A, B C, D) . The previous app generates, lets say 5 records (or 
> rows) that need to be added into the table. So in order to transfer those 
> 5 records, they are named (A1,B1,C1,D1) then (A2,B2,C2,D2) and so on up to

> 5 different records. At the moment they arrive into this script, the app 
> needs to convert those variables into the oCGI so they can be transfer 
> into the table with LoadFiledsfromarray. Said that, A1 is converted into 
> oCGI["A"], B1 into oCGI["B"], etc.  and added into the
table with the 
> Load... method. Then the next record (A2, B2, etc) has to go to the same 
> process, A2 is converted into oCGI["A"], etc... That is why the
process is 
> inside a loop. Because we don´t know how many records the user will 
> generate, the loop with the macros solves the problem.
> I don´t know if this is the best and most optimum way to do it. maybe 
> there is an easier an faster way.
>
> Claus Mygind Wrote:
>
>> Great! I am glad it worked out for you.
>>
>> But the "loadFieldsFromArray" is setup to handle a variable
number of 
>> oCGI
>> elements.  And while there may be oCGI elements that do not match the 
>> name
>> of the fields in your .dbf table, they will automatically be ignored. 
If
>> the data fields (elements) on your .html screen match the names of the

>> .dbf
>> fields both in name and case, then the process would be automatic. ie:
>> oCGI['Name'] = t1.Name
>>
>> You should only have to manipulate the data in a variable if you want
to
>> format the data or some such thing.
>>
>> Well if it works for you that good and nothing further needs to be
said.
>> Claus
>>
>> "Horacio Echeverria" <horacioeg@yahoo.com> wrote in
message
>> news:g5bhItShIHA.1564@news-server...
>> > Claus,
>> >
>> > Thank you for your answer. Following your advice of cutting the
fiields
>> > one by one, I solved the problem that was in the table itself. The

>> > first
>> > field had a 1 character space rather than 2, so the "16"
wasn´t 
>> > entering
>> > in to that field.
>> > The reason I'm using a macro, is that the html that sends the data
into
>> > the script, can send a different number of value/pair variables,
each
>> > time, so that solves the problem. Sometimes it can send 1 set of 
>> > variables
>> > and sometimes 40, 50 or whatever the previous script generates.
>> > Thanks again
>> > Horacio
>> >
>> >
>> > Claus Mygind Wrote:
>> >
>> >> Why are you running a macro to create each variable?
>> >> >                varpap="tipap16_"+LTRIM(STR(K))
>> >>
>> >> >               
oCGI["tipap"]=oCGI["&varpap"]
>> >> Usually these two lines would be written as
>> >>                 varpap = "tipap16_"+LTRIM(STR(K))
>> >>
>> >>                 oCGI["tipap"] = varpap
>> >>
>> >> Where is "K" comming from?
>> >>
>> >> Typically when you use the webClass.cc you are either
streaming out a
>> >> response page from the server or you are reading a .html page
the user
>> >> has
>> >> submitted to the server.
>> >>
>> >> From your description "loadFieldsFromArray" you must
be reading an 
>> >> .html
>> >> page.  In which case the oCGI array would have been created
when you 
>> >> used
>> >> the
>> >>
>> >>      Set proc to WebClass.cc additive
>> >>      oCGI = new CGISession ()
>> >>
>> >> If that is so then you already have some data in the oCGI
array.  If 
>> >> you
>> >> did
>> >> not do this then maybe you don't have the oCGI array created.
>> >>
>> >> If you are creating additional oCGI elements based on
"K", then you do
>> >> not
>> >> have those in the the oCGI array because you did not store
them in 
>> >> there
>> >> in
>> >> first place.
>> >> To do that you would have to write your lines as follows:
>> >>
>> >>  oCGI["tipap"]="tipap16_"+LTRIM(STR(K))
//just one line not two.
>> >>
>> >> Can you translate the error message to English?
>> >>
>> >> Usually this type of problem comes up because one of your
fields are
>> >> defaulting to the wrong type.
>> >>
>> >> Try cutting down on the fields that are processed.  Eventually
you 
>> >> will
>> >> hit
>> >> the one that is creating the problem.
>> >>
>> >> Claus
>> >>
>> >>
>> >> "Horacio Echeverria" <horacioeg@yahoo.com>
wrote in message
>> >> news:t55JkOOhIHA.1864@news-server...
>> >> >I am getting an error in my web app that makes reference
to the
>> >> >webclass.cc
>> >> >when I use the loadFieldsFromArray method. I need to add
rows to a 
>> >> >table
>> >> >and they could be in different numbers depending on the
previous app
>> >> >results. I'm using the method to add a row in the first
instruction,
>> >> >(working fine) and then there is a loop that takes the
value/pairs 
>> >> >from
>> >> >the
>> >> >previous app and the it attempts to add the each row in
tha table 
>> >> >(there
>> >> >is
>> >> >where it cracks) Here is the extract of the app :
>> >> >
>> >> >       * Save in cotizaciones1.dbf
>> >> >
>> >> >        
oCGI.loadFieldsFromArray(COTIZACIONES1.rowset.fields, true)
>> >> >
>> >> >         * guarda en pliegos.dbf
>> >> >
>> >> >         cpliegos16=VAL(oCGI["pliegos16"])
>> >> >
>> >> >         IF cpliegos16>0
>> >> >
>> >> >            FOR K=1 TO cpliegos16
>> >> >
>> >> >                varpap="tipap16_"+LTRIM(STR(K))
>> >> >               
vartft="tinfte16_"+LTRIM(STR(K))
>> >> >               
vartvt="tinvta16_"+LTRIM(STR(K))
>> >> >               
varbmfte="bmfte16_"+LTRIM(STR(K))
>> >> >               
varbmftereg="bmftereg16_"+LTRIM(STR(K))
>> >> >               
varbmvta="bmvta16_"+LTRIM(STR(K))
>> >> >               
varbmvtareg="bmvtareg16_"+LTRIM(STR(K))
>> >> >               
vartiplam="tiplam16_"+LTRIM(STR(K))
>> >> >
>> >> >               
varplianc="plianc16_"+LTRIM(STR(K))
>> >> >               
varplilar="plilar16_"+LTRIM(STR(K))
>> >> >               
varplinum="plinum16_"+LTRIM(STR(K))
>> >> >               
varpapanc="papanc16_"+LTRIM(STR(K))
>> >> >               
varpaplar="paplar16_"+LTRIM(STR(K))
>> >> >               
varcanpaq="canpaq16_"+LTRIM(STR(K))
>> >> >               
varcanpli="canpli16_"+LTRIM(STR(K))
>> >> >               
varentranpli1="entranpli116_"+LTRIM(STR(K))
>> >> >               
varentranpli2="entranpli216_"+LTRIM(STR(K))
>> >> >               
varentranplitot="entranplitot16_"+LTRIM(STR(K))
>> >> >               
varmerma1="merma116_"+LTRIM(STR(K))
>> >> >               
varmerma2="merma216_"+LTRIM(STR(K))
>> >> >               
varcostpap="costpap16_"+LTRIM(STR(K))
>> >> >               
varentranmaq1="entranmaq116_"+LTRIM(STR(K))
>> >> >               
varentranmaq2="entranmaq216_"+LTRIM(STR(K))
>> >> >               
varentranmaqtot="entranmaqtot16_"+LTRIM(STR(K))
>> >> >               
varmaquina="maquina16_"+LTRIM(STR(K))
>> >> >               
varprecio2="precio216_"+LTRIM(STR(K))
>> >> >               
varparreglo="parreglo16_"+LTRIM(STR(K))
>> >> >               
varplamina="plamina16_"+LTRIM(STR(K))
>> >> >               
varttotal="ttotal16_"+LTRIM(STR(K))
>> >> >
>> >> >             oCGI["tipo_pliego"]="16"
>> >> >               
oCGI["tipap"]=oCGI["&varpap"]
>> >> >               
oCGI["tinfte"]=oCGI["&vartft"]
>> >> >               
oCGI["tinvta"]=oCGI["&vartvt"]
>> >> >               
oCGI["bmfte"]=oCGI["&varbmfte"]
>> >> >               
oCGI["bmftereg"]=oCGI["&varbmftereg"]
>> >> >               
oCGI["bmvta"]=oCGI["&varbmvta"]
>> >> >               
oCGI["bmvtareg"]=oCGI["&varbmvtareg"]
>> >> >               
oCGI["tiplam"]=oCGI["&vartiplam"]
>> >> >               
oCGI["plianc"]=oCGI["&varplianc"]
>> >> >               
oCGI["plilar"]=oCGI["&varplilar"]
>> >> >               
oCGI["plinum"]=oCGI["&varplinum"]
>> >> >               
oCGI["papanc"]=oCGI["&varpapanc"]
>> >> >               
oCGI["paplar"]=oCGI["&varpaplar"]
>> >> >               
oCGI["canpaq"]=oCGI["&varcanpaq"]
>> >> >               
oCGI["canpli"]=oCGI["&varcanpli"]
>> >> >               
oCGI["entranpli1"]=oCGI["&varentranpli1"]
>> >> >               
oCGI["entranpli2"]=oCGI["&varentranpli2"]
>> >> >               
oCGI["entranplitot"]=oCGI["&varentranplitot"]
>> >> >               
oCGI["merma1"]=oCGI["&varmerma1"]
>> >> >               
oCGI["merma2"]=oCGI["&varmerma2"]
>> >> >               
oCGI["costpap"]=oCGI["&varcostpap"]
>> >> >               
oCGI["entranmaq1"]=oCGI["&varentranmaq1"]
>> >> >               
oCGI["entranmaq2"]=oCGI["&varentranmaq2"]
>> >> >               
oCGI["entranmaqtot"]=oCGI["&varentranmaqtot"]
>> >> >               
oCGI["maquina"]=oCGI["&varmaquina"]
>> >> >               
oCGI["precio2"]=oCGI["&varprecio2"]
>> >> >               
oCGI["parreglo"]=oCGI["&varparreglo"]
>> >> >               
oCGI["plamina"]=oCGI["&varplamina"]
>> >> >               
oCGI["ttotal"]=oCGI["&varttotal"]
>> >> >
>> >> >               
oCGI.loadFieldsFromArray(PLIEGOS.rowset.fields,
>> >> > true) --->HERE IS WHERE IT CRACKS. NOT EVEN ADD ONE
ROW)
>> >> >
>> >> >            NEXT K
>> >> >
>> >> >         ENDIF
>> >> >
>> >> > The reference in the webclass where the erros is is the
following :
>> >> >
>> >> > Function loadFieldsFromArray(rowsetFields,bAppend)
>> >> >
>> >> >      bAppend = iif(empty(bAppend),false,true)
>> >> >
>> >> >      rf = rowsetFields  // Create private instance of
param
>> >> >
>> >> >      ////// If bAppend, make new row
>> >> >      if bAppend
>> >> >         rf.parent.beginAppend()
>> >> >      endif
>> >> >
>> >> >      ////// Establish first key
>> >> >      cKey = this.firstKey
>> >> >
>> >> >      ///// Traverse the array
>> >> >      for n = 1 to this.count()
>> >> >
>> >> >         if type('rf[cKey]') = 'O'  // if field exists
>> >> >
>> >> >            with (rf[ckey])         // with (field)
>> >> >
>> >> >               if type  = "LOGICAL"   // convert
text to type and 
>> >> > store
>> >> >
>> >> >                  value = iif(upper(this[cKey]) ='TRUE' or
;
>> >> >                           upper(this[cKey]) =
'Y',true,false)
>> >> >
>> >> >               elseif type = "NUMERIC" or ;
>> >> >                  type = "INTEGER" or ;
>> >> >                  type = "DOUBLE" or ;
>> >> >                  type = "FLOAT" or ;
>> >> >                  type = "LONG"
>> >> >
>> >> >                  value = val(this[cKey]) --> THIS IS
THE LINE WHERE
>> >> > THED
>> >> > ERROR OCCURS.
>> >> >
>> >> >               elseif type = "DATE"
>> >> >
>> >> >                  value = ctod(this[cKey])
>> >> >
>> >> >               elseif type = "AUTOINC" or ;
>> >> >                      type = 'TIMESTAMP' or ;
>> >> >                      type = 'BINARY' or ;
>> >> >                      type = 'OLE'
>> >> >
>> >> >                    // do nothing!! Autoincrement is
automatic
>> >> >                    // and the others not supported in
HTML
>> >> >
>> >> > The error is not clear because it attempts to make a
Spanish
>> >> > translation
>> >> > (I think so ¿?). Anyway, the error is :
>> >> >
>> >> > An error ocurred on the server
>> >> >
>> >> >  File: c:\apache\www\impressive\cgibin\Webclass.cc
>> >> >  Line No:759
>> >> >  Database Engine Error: Error de traducción. Traducción
NO 
>> >> > REALIZADA.
>> >> >
>> >> >  Contact the WebMaster
>> >> >
>> >> >
>> >> > Any help will be appreciated.
>> >> >
>> >> > Thank you
>> >> >
>> >> > Horacio Echeverria
>> >> >
>> >> >
>> >>
>> >>
>> >
>>
>>
> 

Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact