save an array on text

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

save an array on text

Post 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
Last edited by Silvio.Falconi on Wed May 13, 2020 2:04 pm, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: PRINT AN ARRAY

Post by Otto »

Silvio, you can download an example here:

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

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: PRINT AN ARRAY

Post 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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: save an array on text

Post by Otto »

I am sorry - I saw on your code Function PrintArray( arr, lNoNewLine ).
Therefore I thought you like to print the array.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: save an array on text

Post by Otto »

Can't you use copy to SDF?
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Post 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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Post 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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: save an array on text

Post 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 )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Post by Silvio.Falconi »

????????
I have a dbf
I muse make dbf ---> txt as array to inserted on my application
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: save an array on text

Post 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Post by Silvio.Falconi »

Thanks Rao

Image
I need it for have Labels measures
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply