FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour save an array on text
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
save an array on text
Posted: Wed May 13, 2020 10:52 AM
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 (fw): Select all Collapse
 

#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: PRINT AN ARRAY
Posted: Wed May 13, 2020 01:49 PM
Silvio, you can download an example here:

viewtopic.php?f=3&t=36878&p=220051&hilit=ERArray.jpg#p220051

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: PRINT AN ARRAY
Posted: Wed May 13, 2020 02:03 PM
Otto wrote:Silvio, you can download an example here:

viewtopic.php?f=3&t=36878&p=220051&hilit=ERArray.jpg#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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: save an array on text
Posted: Wed May 13, 2020 02:27 PM
I am sorry - I saw on your code Function PrintArray( arr, lNoNewLine ).
Therefore I thought you like to print the array.
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: save an array on text
Posted: Wed May 13, 2020 02:29 PM

Can't you use copy to SDF?

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: save an array on text
Posted: Wed May 13, 2020 03:19 PM
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: save an array on text
Posted: Wed May 13, 2020 03:23 PM
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: save an array on text
Posted: Wed May 13, 2020 03:41 PM
Then you want to read an array which is stored in a file. Is this what you want?
Code (fw): Select all Collapse
    aTest := ARead ( memoread("Test.txt" ) )
   
   cBinData := ASave( aTest )                   // Converts Array Data and to Binary and stores in cStr
   
   memowrit( "Test2.txt", cBinData )
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: save an array on text
Posted: Wed May 13, 2020 03:49 PM

????????
I have a dbf
I muse make dbf ---> txt as array to inserted on my application

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: save an array on text
Posted: Wed May 13, 2020 05:58 PM
I suggest this code:
Code (fw): Select all Collapse
   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 )


Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: save an array on text
Posted: Wed May 13, 2020 11:57 PM
Thanks Rao


I need it for have Labels measures
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion