Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ObjectPal Create (a table) command 1

Status
Not open for further replies.

LWB

Technical User
Feb 4, 2003
95
US
I'm trying to create a table borrowing all the structure, indexes, and validity checks from an existing table. If I only use the LIKE command it works, but the STRUCT and INDEXSTRUCT generate errors (used alone or together).

The code is:

method pushButton(var eventInfo Event)
var
NewTbl Table
OldTbl Table
endVar

OldTbl.attach("oldfile.db")
NewTbl = Create "newfile.db"
Like OldTbl
Struct OldTbl
indexStruct OldTbl
EndCreate
errorshow()
endMethod

Including the Struct line generates the error "FieldName not a field in oldfile"

Including the indexStruct generates the error "Infoleader not a field in oldfile"

If I only include the Like line, it doesn't generate errors.

What am I doing wrong? (I'm using Paradox 9)

Lynn
 
Lynn,
To use Struct you must first generate a table that describes the table structure. You do this by first using enumFieldStruct(). Similar logic applies to indexStruct. Try this:

method pushButton(var eventInfo Event)
var
NewTbl Table
OldTbl Table
endVar

OldTbl.attach("oldfile.db")
;generate temp table with the field struct
if not OldTbl.enumFieldStruct(":pRIV:TEMPSTR.DB") then
errorShow()
return
endif
;generate temp table with the index struct
if not OldTbl.enumIndexStruct(":pRIV:TEMPIDX.DB") then
errorShow()
return
endif
;create the table
NewTbl = Create "newfile.db"
Struct ":pRIV:TEMPSTR.DB"
indexStruct "PRIV:TEMPIDX.DB"
EndCreate

;to tidy up insert some code to delete the temp tables

endMethod

HTH
Padraig
 
Thanks. That did the trick.

Lynn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top