Page 1 of 1

save an array on text

Posted: Wed May 13, 2020 10:52 am
by Silvio.Falconi
I need to save on source code a big dbf
I'm thinking to save an array without use the dbf

I tried to make a test but it not run ok
where is the error ?

Code: Select all

 

#include "fivewin.ch"

Function test()
local aData:={}
local cCode := ""

USE CUSTOMER ALIAS CUSTOMER

   aData:=CUSTOMER->(FW_DbfToArray())



       cCode:=PrintArray( adata,  .T. )


   MemoEdit( cCode, FWString( "Code" ) )

   return nil


//-------------------------------------------------------------------------//
Function PrintArray( arr, lNoNewLine )
Local i
local ctxt:=""
 
   IF lNoNewLine == Nil .OR. !lNoNewLine
    ctxt:="error"
 ENDIF

   ctxt+= " {"
   FOR i := 1 TO Len( arr )
      IF Valtype( arr[i] ) == "A"
         PrintArray( arr[i], .T. )
      ELSE
    
         ctxt+= " " + Iif( Valtype( arr[i] ) == "N", ltrim(Str(arr[i])), ;
                      Iif( Valtype( arr[i] ) == "D", Dtos(arr[i]),arr[i]) )


      ENDIF
   NEXT
   ctxt+= " }"

Return  ctxt

Re: PRINT AN ARRAY

Posted: Wed May 13, 2020 1:49 pm
by Otto
Silvio, you can download an example here:

https://forums.fivetechsupport.com/view ... pg#p220051

Image

Re: PRINT AN ARRAY

Posted: Wed May 13, 2020 2:03 pm
by Silvio.Falconi
Otto wrote:Silvio, you can download an example here:

https://forums.fivetechsupport.com/view ... pg#p220051
help me I don't know how to tell you

I'm not interested in ER and Mod_HArbour

No estoy interesado en ER y Mod_HArbour

Ich interessiere mich nicht für ER und Mod_HArbour

Wenn Sie mir helfen möchten, mir über die Nachricht zu antworten, die ich geschrieben habe

Re: save an array on text

Posted: Wed May 13, 2020 2:27 pm
by Otto
I am sorry - I saw on your code Function PrintArray( arr, lNoNewLine ).
Therefore I thought you like to print the array.

Re: save an array on text

Posted: Wed May 13, 2020 2:29 pm
by Otto
Can't you use copy to SDF?

Re: save an array on text

Posted: Wed May 13, 2020 3:19 pm
by Silvio.Falconi
Otto wrote:I am sorry - I saw on your code Function PrintArray( arr, lNoNewLine ).
Therefore I thought you like to print the array.
but even if I had called the function with "Printarray" because every time I put a message you have to force me to be pissed off because you want me to use ER or Mod_harbour?
I understand that you are not interested in making changes on ER
because it works for you as it is
however don't be surprised if only you use ER
no one else I know uses ER

Re: save an array on text

Posted: Wed May 13, 2020 3:23 pm
by Silvio.Falconi
Otto wrote:Can't you use copy to SDF?
no
I wish create a source code
i wish insert this source code into my application
because I not want use that dbf
I could write it by hand but it would take me a lifetime
I don't have to print that array
I need an array to insert on My function because the final use can select an item from array and not from dbf

Re: save an array on text

Posted: Wed May 13, 2020 3:41 pm
by Otto
Then you want to read an array which is stored in a file. Is this what you want?

Code: Select all

    aTest := ARead ( memoread("Test.txt" ) )
   
   cBinData := ASave( aTest )                   // Converts Array Data and to Binary and stores in cStr
   
   memowrit( "Test2.txt", cBinData )

Re: save an array on text

Posted: Wed May 13, 2020 3:49 pm
by Silvio.Falconi
????????
I have a dbf
I muse make dbf ---> txt as array to inserted on my application

Re: save an array on text

Posted: Wed May 13, 2020 5:58 pm
by nageswaragunupudi
I suggest this code:

Code: Select all

   local aData, cData

   USE CUSTOMER
   aData := FW_DbfToArray()
   CLOSE CUSTOMER

   cData := FW_ValToExp( aData )
   cData := StrTran( cData, "},{", "} ;" + CRLF + ",  {" )
   cData := StrTran( cData, "{{", "function customer_array()" + CRLF + "return ;" + CRLF + "{  {" )
   cData := Left( cData, Len( cData ) - 1 ) + " ;" + CRLF + "}" + CRLF

   FW_MEMOEDIT( cData )
 
Image

Re: save an array on text

Posted: Wed May 13, 2020 11:57 pm
by Silvio.Falconi
Thanks Rao

Image
I need it for have Labels measures