Macros and Programming


CardboxForumsMacros and Programming > "Help converting Cardbox2 macro to Cardbox 3"

Help converting Cardbox2 macro to Cardbox 3

Posted By Post


6-Sep-2012 15:24

Can someone help me convert an old cardbox2 macro to cardbox3? (see below)

With two windows open on the same database, and each one containing a selection of sorted duplicate records, it copies some bibliographic reference information from one record to the (near) duplicate, then moves on and repeats all the way through. The only difference between the records is in one field. Afterwards, I delete one of the duplicate selections.

' Copies DI Field from Biol to dup MED record
 *Text Moveto-DI SelectAll Copy
 *SwitchTo "CCSEP1.FIL"
 *Text Moveto-DI End " / " Paste Moveto-CL End " AND BIOL"
 *SwitchTo "CCSEP1.FIL #2"

Happy to pay if it is a hassle to do and also, for the record, it would be useful to know who can write macros for me if I need the service in the future.




6-Sep-2012 17:03

This is it. This is the most simple translation.
There are much more advanced ways to macro this.
But for a beginner this is ok:

'first store the name of the first db in a variable
win = Caption

'start the loop from current record until end of selection
for rec = RecordPosition to Records.Count

'read the content of field DI in variable x
x = Fields("DI")

'Swichto the other window named CCSEP1
Activate "CCSEP1"

'Record in edit mode

'Field DI = field DI + " / " + content of CI stored into var x
Fields("DI") = Fields("DI") & " / " & x

'fields CL = fields cl + " AND BIOL"
Fields("CL") = Fields("CL") & " AND BIOL"

'Save the record

'NextRecord in current db

'Switch back to the window where it started
Activate win

'NextRecord in window x

'next time the loop

Test it first on one record...!
Hint: try also to record macro's and see the result. You will see it is less difficult then you think.



7-Sep-2012 15:27

Hey Bert,

You are a star!

It didn't work the first time, but when I stripped out your comments, it worked fine! Not sure why that would be, but I will check again as it will be good to have your comments in there.

I did try to record it but hit a bit of a brick wall. I'll have to try again..

I can't thank you enough!

Do you ever do freelance work? If I had a bigger project, I'd hate to bug anyone for free.

Thanks again :)



7-Sep-2012 17:03

Do you ever do freelance work?: Cardbox projects: yes...

© 2010 Cardbox Software Limited   Home