Building a database by procedure
Mark Terry
mark at abernackie.com
Thu Feb 21 10:53:44 PST 2008
On Feb 21, 2008, at 1:26 PM, Steve Tyron wrote:
>
> Question: what method would let me collect all contents of Record 1
> into
> an array ("lineNum, title, author, blurb..." etc) and then set the
> names
> of the columns with that array? I will also need to add new columns
> and
> name those, and of course these all have to be in a specific order.
>
> Can this be done?
Below is a procedure I keep in a db that's open most of the time.
After opening a text file (in Panorama) with field names in the first
one (or two) records, I position it just below the db that has the
procedure. It would be simple to implement a dialog that asks you to
select the database, but here, it just works on whatever window is
below it. This proc does not remove the fieldname record(s)
automatically (I always like to eyeball first).
local WIN
WIN= info("WindowName") ;find out where you are
window array(info("windows"),2,¶) ;go to the db below
FirstRecord
Loop Left until stopped ;get to the first record in the first column
if info("modifiers")="" ;normal situation
Loop fieldname «» right until stopped ;left chevron, right chevron
/*this is for those db's/spreadsheets with long fieldnames broken into
two records!*/
else
local ONE,TWO
loop
ONE=«»
DownRecord
TWO=«»
UpRecord
fieldname strip(ONE+" "+TWO)
right
until stopped
endif
window WIN ;back to square 1
Also, an easy way to get the contents of a record into an array is
with the exportline( function.
M
More information about the Qna
mailing list