Multiple array is giving me problems (SOLVED)

Multiple array is giving me problems (SOLVED)

Postby Marc Venken » Mon Dec 14, 2020 9:34 am

It should be easy, but .....

The code reads the XML, and is giving me a correct Xbrowse with the data

Writing it to dbf is a problem. Tried also with FW_arraytodbf
What do I miss here ??

Is there somewhere a post on multiply arrays explanations ? I have find some...


I get this error

Application
===========
Path and name: C:\Programmas\fotoselect\TEST.EXE (32 bits)
Size: 5,078,016 bytes
Compiler version: Harbour 3.2.0dev (r2008190002)
FiveWin version: FWH 20.08
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 2 mins 41 secs
Error occurred at: 14/12/2020, 10:28:42
Error description: Error DBFCDX/1020 Data type error: HEXCODE
Args:
[ 1] = U

Stack Calls
===========
Called from: .\TEST1.PRG => XMLREADER( 12166 )
Called from: .\TEST1.PRG => (b)BUILDMENU( 5745 )
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 1556 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1141 )
Called from: .\source\classes\MDIFRAME.PRG => TMDIFRAME:COMMAND( 272 )
Called from: => TMDIFRAME:HANDLEEVENT( 0 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1097 )
Called from: .\TEST1.PRG => MAIN( 71 )

System
======

Code: Select all  Expand view

function Xmlreader()
   local aMail:={},nTel:= 1, i
   local hFile    := FOpen( "c:\programmas\fotoselect\kleuren.xml"  )
   Local oXmlDoc  := TXmlDocument():New( hFile )
   Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
   //FW_XmlView( hFile )

   nTel = 1
   while .T.
      oTagActual = oXmlIter:Next()
      If oTagActual != nil
         //if oTagActual:cName = "item"
         //   aadd(aMail,oTagActual:cData)
         //endif
         if oTagActual:cName = "colorHex"
           cHex = oTagActual:cData
           do while .t.
             oTagActual = oXmlIter:Next()
             If oTagActual != nil
               if oTagActual:cName = "dutch"
                  cdd = oTagActual:cData //+ " : "+cHex
                  aadd(aMail ,{cdd,cHex} )
                  nTel++
                  exit
               endif
             endif
           enddo
         endif
      Else
         Exit
      Endif
   End
   aStruct := {}
   AADD(aStruct, { "kleuren", "C", 70, 0 }) // Id
   AADD(aStruct, { "hexcode", "C", 10, 0 }) // Id

  DbCreate( "shopcolor.dbf", aStruct)
  use shopcolor NEW

  xbrowser(aMail)

  for i = 1 to len(aMail)
     ckleur = amail[i,1]
     cHex = aMail[i,2]
     shopcolor->(dbappend())
     shopcolor->kleuren = cKleur
     shopcolor->hexcode = Chex
  next

   xbrowser("shopcolor")

   FClose( hFile )
   close all

return nil

 
Last edited by Marc Venken on Mon Dec 14, 2020 12:13 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Multiple array is giving me problems

Postby Antonio Linares » Mon Dec 14, 2020 10:10 am

Marc,

fields assignment must use ":="

shopcolor->kleuren := cKleur
shopcolor->hexcode := Chex
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multiple array is giving me problems

Postby Enrico Maria Giordano » Mon Dec 14, 2020 11:14 am

Antonio Linares wrote:Marc,

fields assignment must use ":="

shopcolor->kleuren := cKleur
shopcolor->hexcode := Chex


It's not true. In that context, the two operators = and := are equivalent.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8709
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multiple array is giving me problems

Postby Marc Venken » Mon Dec 14, 2020 11:47 am

I'm almost positive that the array is the problem

aMail and his 2 dimensions
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Multiple array is giving me problems

Postby Antonio Linares » Mon Dec 14, 2020 12:03 pm

Enrico Maria Giordano wrote:
Antonio Linares wrote:Marc,

fields assignment must use ":="

shopcolor->kleuren := cKleur
shopcolor->hexcode := Chex


It's not true. In that context, the two operators = and := are equivalent.

EMG


Enrico,

It works because the alias is specified. Remove the alias and it will fail.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multiple array is giving me problems

Postby Marc Venken » Mon Dec 14, 2020 12:06 pm

Antonio Linares wrote:Marc,

fields assignment must use ":="

shopcolor->kleuren := cKleur
shopcolor->hexcode := Chex


Same error...
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Multiple array is giving me problems

Postby Antonio Linares » Mon Dec 14, 2020 12:09 pm

Marc,

It fails because the field "hexcode" is type char and you are assigning it a nil value:

aadd( aMail ,{ cdd, If( cHex == nil, "", cHex ) } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multiple array is giving me problems

Postby Marc Venken » Mon Dec 14, 2020 12:13 pm

Antonio Linares wrote:Marc,

It fails because the field "hexcode" is type char and you are assigning it a nil value:

aadd( aMail ,{ cdd, If( cHex == nil, "", cHex ) } )


Indeed... This solved my problem and i think other problems I had before also. Never thinking of a NIL value..

Thank You !!
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Multiple array is giving me problems

Postby Enrico Maria Giordano » Mon Dec 14, 2020 1:39 pm

Antonio Linares wrote:Enrico,

It works because the alias is specified. Remove the alias and it will fail.


No, without the alias it won't work (= or := is the same) because it's referring to a MEMVAR variable and not to the DBF field.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8709
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multiple array is giving me problems (SOLVED)

Postby Antonio Linares » Mon Dec 14, 2020 3:34 pm

Enrico,

? fieldname

shows the field contents if exists
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multiple array is giving me problems (SOLVED)

Postby Enrico Maria Giordano » Mon Dec 14, 2020 3:47 pm

Yes, but please try this sample. It doesn't write the value to the field.

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    USE CUSTOMER

    ? last

    last := "TEST"

    ? last

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8709
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multiple array is giving me problems (SOLVED)

Postby Antonio Linares » Mon Dec 14, 2020 5:14 pm

Dear Enrico,

You are right
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests