Page 1 of 1

Flexfile memo arrays workaround

Posted: Wed Jul 06, 2011 11:48 am
by Tim K
Hi Roger:

I talked to you before about my clipper app I want to convert to XBASE++ that uses the Flexfile arrays. You said you were able to use strings to emulate that structure. Do you have a tool or some code to work from?

Tim Kromholtz
Ziegler Lumber Company

Re: Flexfile memo arrays workaround

Posted: Wed Jul 06, 2011 1:34 pm
by rdonnay
Tim -

The function DC_Ar2Str() will convert a multi-dimensional array to a string that can then be stored to a database field.

You then used DC_Str2Ar() to read the database field and convert it back to an array.

Code: Select all

aDir := Directory()

REPLACE MYDATABASE->directory WITH DC_Ar2Str(aDir)

aDir := DC_Str2Ar(MYDATABASE->directory)

Re: Flexfile memo arrays workaround

Posted: Fri Jul 08, 2011 2:34 pm
by Tim K
Shall I pull out the code I need from _dcasave.prg to link into my clipper app? It will have to be usable in my original app since it is the only thing that will read flexfile memo arrays, unless I'm missing something.

Re: Flexfile memo arrays workaround

Posted: Sat Jul 09, 2011 2:59 pm
by rdonnay
Shall I pull out the code I need from _dcasave.prg to link into my clipper app?
Yes, this is fully Clipper compatible code.

Re: Flexfile memo arrays workaround

Posted: Tue Jul 12, 2011 3:24 pm
by Tim K
I'm getting a C "math error M6104 floating-point overflow" when L2BIN() in function _dcitem() tries to convert a 10 digit integer (13123020000). I don't see any documentation in the clipper guide on limits on this function. This isn't greater than the largest 32 bit decimal (4294967295), any ideas?

Re: Flexfile memo arrays workaround

Posted: Tue Jul 12, 2011 5:00 pm
by rdonnay
Xbase++ also gives a numeric overflow with numbers that are too long.

If you are storing large numerics in arrays, we may need to treat them as a type "F" (floating point).

Try changing the _dcItem() code like so:

Code: Select all

Was:

   CASE cType == "N"  // numeric
      IF '.'$STR(xItem) 
        xItem := STR(xItem)
        cRetVal := "F"+l2Bin( len( xItem)) + xItem
      ELSE
        cL2bin := l2bin(xItem)
        IF CHR(26)$cL2bin
          cRetVal := "W"+DC_l2Dec(xItem)
        ELSE
          cRetVal := "N"+l2bin(xItem)
        ENDIF
      ENDIF

Is:

   CASE cType == "N"  // numeric
      IF '.'$STR(xItem) .OR. xItem > 100000000
        xItem := STR(xItem)
        cRetVal := "F"+l2Bin( len( xItem)) + xItem
      ELSE
        cL2bin := l2bin(xItem)
        IF CHR(26)$cL2bin
          cRetVal := "W"+DC_l2Dec(xItem)
        ELSE
          cRetVal := "N"+l2bin(xItem)
        ENDIF
      ENDIF