FW/Clipper Conversion - Handling Stored Arrays

FW/Clipper Conversion - Handling Stored Arrays

Postby arpipeline » 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
User avatar
arpipeline
 
Posts: 36
Joined: Thu Oct 26, 2006 5:23 pm
Location: United States

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby nageswaragunupudi » Tue Apr 28, 2009 1: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby arpipeline » Tue Apr 28, 2009 5: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.
User avatar
arpipeline
 
Posts: 36
Joined: Thu Oct 26, 2006 5:23 pm
Location: United States

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby nageswaragunupudi » Tue Apr 28, 2009 5: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby nageswaragunupudi » Tue Apr 28, 2009 6:10 am

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

 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby arpipeline » Tue Apr 28, 2009 2: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 .
User avatar
arpipeline
 
Posts: 36
Joined: Thu Oct 26, 2006 5:23 pm
Location: United States

Re: FW/Clipper Conversion - Handling Stored Arrays

Postby nageswaragunupudi » Tue Apr 28, 2009 2: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests