Page 1 of 1

FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Mon Apr 27, 2009 10:46 pm
by arpipeline
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

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 1:29 am
by nageswaragunupudi
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 )

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 5:04 am
by arpipeline
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.

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 5:33 am
by nageswaragunupudi
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 )

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 6:10 am
by nageswaragunupudi
I used this function long time back.
Code: Select all  Expand view
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

 

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 2:08 pm
by arpipeline
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 .

Re: FW/Clipper Conversion - Handling Stored Arrays

PostPosted: Tue Apr 28, 2009 2:12 pm
by nageswaragunupudi
>
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.