Defining a database record
Now, define a record that sends a request to the detabase row. To define a database record, do the following:
1. In the Organizer, add to MyDatabaseTCPIP a Smalltalk class named MyDatabaseRecord which inherits from AbtForeignOSObject.
2. Add a class method to MyDatabaseRecord:
how 
initializeAfterLoad
"Initialize the fixed size for this OSPtr subclass."
self fixedSize: 2018
3. In a Public Interface Editor, add the attribute hostVar and specify Integer for its data type. Next, add the attributes password, results, and userid; use the defaults with a String data type. Finally, generate the default scripts.
On the Action tab, add the initializeWith: action. Do not specify any value for Action selector.
4. In a Script Editor, modify the generated scripts as needed so they resemble the following:
how 
hostVar
"Return the value of field hostVar."
^self int16At: 16
hostVar: obj
"Set the value of field hostVar."
self int16At: 16 put: obj abtAsNumber abrAsCLangShort
password
"Return the value of field password."
^self abtCharArrayAt: 8
length: 8
password: obj
"Set the value of field password."
self abtCharArrayAt: 8
put: obj
length: 8
pad: 0
results
"Return the value of field results."
^self abtCharArrayAt: 18
length: 2000
results: obj
"Set the value of field results."
self abtCharArrayAt: 18
put: obj
length: 2000
pad: 0
userid
"Return the value of field userid."
^self abtCharArrayAt: 0
length: 8
userid: obj
"Set the value of field userid."
self abtCharArrayAt: 0
put: obj
length: 8
pad: 0
5. Add the following instance methods to MyDatabaseRecord:
how 
data
^(self memcpyFrom: 0 to: self class fixedSize - 1)
initializeWith: aString
aString contents
memcpyFrom: 0
to: (aString size min: self class fixedSize) -1
into: self startingAt: 0.
size
^self class fixedSize
Last modified date: 01/29/2015