save an array on text

save an array on text

Postby Silvio.Falconi » 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: Select all  Expand view


#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.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm

Re: PRINT AN ARRAY

Postby Otto » Wed May 13, 2020 1:49 pm

Silvio, you can download an example here:

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

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6013
Joined: Fri Oct 07, 2005 7:07 pm

Re: PRINT AN ARRAY

Postby Silvio.Falconi » Wed May 13, 2020 2: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Postby Otto » Wed May 13, 2020 2:27 pm

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6013
Joined: Fri Oct 07, 2005 7:07 pm

Re: save an array on text

Postby Otto » Wed May 13, 2020 2:29 pm

Can't you use copy to SDF?
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6013
Joined: Fri Oct 07, 2005 7:07 pm

Re: save an array on text

Postby Silvio.Falconi » Wed May 13, 2020 3: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Postby Silvio.Falconi » Wed May 13, 2020 3: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Postby Otto » Wed May 13, 2020 3:41 pm

Then you want to read an array which is stored in a file. Is this what you want?
Code: Select all  Expand view

    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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6013
Joined: Fri Oct 07, 2005 7:07 pm

Re: save an array on text

Postby Silvio.Falconi » Wed May 13, 2020 3: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm

Re: save an array on text

Postby nageswaragunupudi » Wed May 13, 2020 5:58 pm

I suggest this code:
Code: Select all  Expand view
  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
nageswaragunupudi
 
Posts: 10250
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: save an array on text

Postby Silvio.Falconi » Wed May 13, 2020 11:57 pm

Thanks Rao

Image
I need it for have Labels measures
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6783
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], karinha and 10 guests