Copying of records of open databases in style with pseudonym

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Copying of records of open databases in style with pseudonym

#1 Post by Eugene Lutsenko »

How to copy all records of one database in another if both of them are open (COPY FILE not to use) in style with pseudonyms? As in this style the functional analog of the program will look:

Code: Select all

        SELECT Abs
        DBGOTOP()
        DO WHILE .NOT. EOF()
           Ar := {}
           FOR j=1 TO FCOUNT()
               AADD(Ar, FIELDGET(j))
           NEXT
           SELECT InfVisio
           APPEND BLANK
           FOR j=1 TO LEN(Ar)
               FIELDPUT(j,Ar[j])
           NEXT
           SELECT Abs
           DBSKIP(1)
        ENDDO
Something such as it?

Code: Select all

        Abs->(DBGOTOP())
        DO WHILE Abs->(.NOT. EOF())
           FOR j=1 TO Abs->(FCOUNT())
               InfVisio->(FIELDPUT(j,Abs->FIELDGET(j)))
           NEXT
           Abs->(DBSKIP(1))
        ENDDO
The given option at compilation gives syntactic errors

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Copying of records of open databases in style with pseud

#2 Post by Cliff Wiernik »

Use this inside of a do while loop

Code: Select all

*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+
*+    Function LB_CopyRecord(cSource,cTarget)      
*+
*+      // Copy record to another DBF using Scatter/Gather 
*+
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
*+ 
FUNCTION LB_CopyRecord(cSource,cTarget)      
  LOCAL i
  LOCAL aRpl := {}
  
  SELECT (cSource)      
      
  FOR i := 1 TO (cSource)->(fcount())
     aadd(aRpl,(cSource)->(fieldget(i)))                                        // load array (scatter) with field data
  NEXT

  SELECT (cTarget)
  (cTarget)->(dbappend())
  aeval(aRpl,{|j,i| (cTarget)->(fieldput(i,j)) })                               // put data in new record (gather)
  
  RETURN .T.      

Wolfgang Ciriack
Posts: 484
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Copying of records of open databases in style with pseud

#3 Post by Wolfgang Ciriack »

Hello,
or take a look at the functions

DC_DbRecord, DC_Dbscatter, DC_Dbgather
_______________________
Best Regards
Wolfgang

skiman
Posts: 1199
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Copying of records of open databases in style with pseud

#4 Post by skiman »

Hi,

You could use the dc_gather/dc_scatter but this wouldn't speed it up. I'm wondering if you can use ABS as aliasname, because ABS() is an existing function! This is probably the cause of your syntax errors at compile time.

Code: Select all

Absx->(DBGOTOP())
nFields := absx->(fcount())    // fcount() is a slow function
DO WHILE !Absx->(EOF())
      FOR j=1 TO nFields   // this way the fcount isn't executed each time.
          infvisio->(dbappend())     // you need to append a record
          InfVisio->(FIELDPUT(j,Absx->FIELDGET(j)))
      NEXT
      Absx->(DBSKIP(1))
ENDDO
Another way would be to make use of dbeval() but I don't think this would make difference in speed.
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Copying of records of open databases in style with pseud

#5 Post by Eugene Lutsenko »

As to Abs - very much can be, I will try to understand... Thanks!

Whether and there is something similar Destroy () after DCBROWSE? And I have that one mode with DCBROWSECOL use after one modes or right after start of system works normally, and after others doesn't display base.

Post Reply