FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FW/Clipper Conversion - Handling Stored Arrays
Posts: 36
Joined: Thu Oct 26, 2006 05:23 PM
FW/Clipper Conversion - Handling Stored Arrays
Posted: Mon Apr 27, 2009 10:46 PM

I have an old Fivewin/Clipper application I am converting to FWH and compiling with licensed xHB pro. The Clipper app uses both ADS and the SIX driver (CDX).

In a few prgs, arrays are stored and retrieved like so:

MyTable->MyField := MyArray

and

MyArray := MyTable->MyField

The arrays were not an issue in the Clipper/FW version...but with FWH and ADS they are throwing a data type error. Has anyone addressed this? I couln't find anything by searching here and in the xHB docs.

BTW, I am using stricly local and and remote ADS for the FWH version of my application.

Thanks

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 01:29 AM

In ADS, only clipper RDD supports storing of arrays. While converting to 32 bit application, we need to do one time job of converting arrays in to strings.

Array is to be converted like "{ 1, 2, SToD( '20090209') }'. Function like ValToPrg( aArray ) --> cString is handy for this.

When we read ...
aVar := &( field->carrayfield )

Regards



G. N. Rao.

Hyderabad, India
Posts: 36
Joined: Thu Oct 26, 2006 05:23 PM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 05:04 AM

I understand how to do it going forward, what I need is to know how to retrieve the arrays and convert them in our existing customers tables. They must be stored in some format that can be decoded. If there is no way, I will need to write a conversion utility in 16-bits for our current customers.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 05:33 AM

In my view we should write a conversion utility in 16 bits clipper. It is a one time conversion.
Present 16 bit application can continue to run with one modification : aValue := &( field->afield )

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 06:10 AM
I used this function long time back.
Code (fw): Select all Collapse
function u2c( uVal )

   local cVal  := ''
   local cType := ValType( uVal )

   do case
   case cType == 'A'
      AEval( uVal, { |u| cVal += ", " + u2c( u ) } )
      cVal     := '{ ' + SubStr( cVal, 2 ) + ' }'
   case cType == 'C'
      cVal     := c2exp( uVal )
   case cType == 'D'
      cVal     := "STOD('" + DTOS( uVal ) + "')"
   case cType == 'N'
      cVal     := LTrim( Str( uVal ) )
   case cType == 'L'
      cVal     := If( uVal, ".t.", ".f." )
   otherwise
      cVal     := 'nil'
   endcase

return cVal

static function c2exp( cVal )

   local cRet
   local nAt

   do case
   case cVal == ''
      cRet  := "''"
   case !( "'" $ cVal )
      cRet  := "'" + cVal + "'"
   case !( '"' $ cVal )
      cRet  := '"' + cVal + '"'
   case !( '[' $ cVal .or. ']' $ cVal )
      cRet  := '[' + cVal + ']'
   otherwise
      nAt   := AT( '"', cVal )
      cRet  := '"' + Left( cVal, nAt - 1 ) + '" + '
      cRet  += ['"']
      cVal  := SubStr( cVal, nAt + 1 )
      if ! Empty( cVal )
         cRet  += "+" + c2exp( cVal )
      endif
   endcase

return cRet
Regards



G. N. Rao.

Hyderabad, India
Posts: 36
Joined: Thu Oct 26, 2006 05:23 PM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 02:08 PM

I'll probably just use XML in a conversion routine or HD_Serialize and HB_Deserialize. Thank you though.

It's hard to believe that there is no way to decode a clipper array out of a memo field -- an array that is nested two and three levels deep. This must have been an RDD thing becuase if IRC, you couldn't save arrays to DBFDBT memos. It's been too long :D .

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FW/Clipper Conversion - Handling Stored Arrays
Posted: Tue Apr 28, 2009 02:12 PM

>
array that is nested two and three levels deep.
>
Above function handles arrays nested to any number of levels

>
I'll probably just use XML in a conversion routine
>

Thats also a good option, except that xml takes a lot more space.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion