SIMPOL Documentation

Chapter 5. The Peer-to-Peer Client/Server (PPCS) Component

Provides access to database files via the Superbase Peer-to-Peer Client/Server protocol. This access is read/write/delete but does not provide the ability to modify the database definition or create or modify database tables.

ppcstype1

Description

Objects of type ppcstype1 are a base from which data available from some PPCS server can be accessed. Each object of type ppcstype1 uses one communication medium such as UDP or a serial port.

Type Tags

db1base

Object Value

Objects of type ppcstype1 have no value, and it is an error to try to get or set this value.

ppcstype1.new()

Description

Creates a new ppcstype1 object and specifies the nature of the comunication method it will use. Parameters must be specified for exactly one of the possible media.

Prototype

ppcstype1.new ( integer udpport, integer txfactor, integer serialport, integer baudrate, integer parity, integer stopbits, integer error, string username )

Parameters

ParameterDefault valueType nameDescription
udpportNoneinteger The UDP port number to use for the new ppcstype1 object. If this is specified then no parameters for other communication media should be given. If udpport is assigned the value .nul then a random port will be assigned.
txfactor0integer The transmission delay to use when communicating. Generally this does not need to be specified.
serialportNoneinteger The serial port to use for the new ppcstype1 object. If this is specified then no parameters for other communication media should be given.
baudrate19200integer The baud rate to use if the new ppcstype1 object is to use serial communications.
parity0integer The parity to use for serial communications. Permitted values are: 0 (no parity), 1 (odd parity) and 2 (even parity).
stopbits1integer The number of stop bits to use in serial communications. Permitted values are 1 and 2.
error.nulinteger Specifies an object that is used to output any error code generated during the execution of the method. This parameter must be an object, not an integer value. If error is not specified or is .nul then any error that occurs during object creation will halt the program. If an error object is specified and an error occurs during execution then the error code is output into that object and the method returns .nul.
usernameplatform dependentstring The username must be at least one character in length and cannot be greater than eighteen characters in length. The username for a ppcstype1 object is the username used for all operations performed on files opened using the ppcstype1 object.

Properties

PropertyTypeDescription
_type(*) This property is provided for use by the user to attach any object of any type to the type in which this property is provided.
__type(*) This property is provided for use by the user to attach any object of any type to the type in which this property is provided. It has the additional feature of being marked with the resolve keyword, so that object resolution can continue down this property.
parityinteger Contains the parity setting being used, if the object uses serial communications, or .nul if not.
serialportinteger Contains the number of the serial port in use, if the object uses communications, or .nul if not.
stopbitsinteger Contains the number of stop bits being used, if the object uses serial communications, or .nul if not.
txfactorinteger Contains a transmission factor value that can be used to slow down the communication with the other end of the PPCS connection.
typetype Specifies the ppcstype1 type object.
udpportinteger Contains the UDP port number if the object uses UDP, or .nul if not.
usernamestring Contains the username for all PPCS operations performed using the ppcstype1 object.

Methods

gettablenames()

Description

Gets the names of the PPCS files which are available on a specified PPCS server. If the attempt to get the table names is successful then .nul is returned. If the attempt is not successful and neither the error nor errortext parameters are provided then an error is raised. If the attempt is not successful and at least one of the error or errortext parameters are provided then .nul is returned and error information is output in the error or errortext objects provided.

Prototype

ppcstype1var.gettablenames ( string address, array tablenames, string pattern, integer codepage, integer error, string errortext, integer retry, integer timeout )

Parameters
ParameterDefault valueType nameDescription
addressNonestring The internet address, machine name or IP address and port number of the PPCS server providing the file names to be retrieved.
tablenamesNonearray Specifies an object of type array which is used to output the names of the files which are available from the specified server and which match the specified pattern, if any. The first table name, if any, is placed in the array in the position '[1]', the second in position '[2]', and so on. The number of table names retrieved in placed in position '[]'.
pattern""string A pattern used to restrict the table names which will be retrieved. Only names which match the pattern will be output. The matching of a name to a pattern follows the rules for the intrinsic function .like1.
codepage850integer The number of the OEM codepage that will be assumed to be in use by the PPCS server providing the file.
error.nulinteger Specifies an object that is used to output any error code generated during the execution of the method. This parameter must be an object, not an integer value. If error is not specified or is .nul and errortext is not specified or is .nul then any error that occurs during name retrieval will halt the program. If an error object or errortext object is specified and an error occurs during execution then the error code or text is output into that object and the method returns .nul.
errortext.nulstring Specifies an object that is used to output any error text generated during the execution of the method. This parameter must be an object, not a string value. If error is not specified or is .nul and errortext is not specified or is .nul then any error that occurs during name retrieval will halt the program. If an error object or errortext object is specified and an error occurs during execution then the error code or text is output into that object and the method returns .nul.
retry1000000integer The number of microseconds between retries, if the operation is not successful immediately.
timeout5000000integer The number of microseconds allowed for the operation to complete before it is assumed that it will fail.

openudpfile()

Description

Opens a database file on a PPCS server using UDP. The ppcstype1 object for which the method is called must be using UDP. If the attempt to open the file is successful then a reference to an object of type ppcstype1file is returned. If the attempt is not successful and neither the error nor errortext parameters are provided then an error is raised. If the attempt is not successful and at least one of the error or errortext parameters are provided then .nul is returned and error information is output in the error or errortext objects provided.

Prototype

ppcstype1var.openudpfile ( string address, string filename, string password, integer codepage, integer error, string errortext, integer retry, integer timeout, string recordidfieldname )

Parameters
ParameterDefault valueType nameDescription
addressNonestring The internet address, machine name or IP address and port number of the PPCS server providing the file to be opened.
filenameNonestring The name of the file to open.
passwordNonestring The password to be used to access the file.
codepage850integer The number of the OEM codepage that will be assumed to be in use by the PPCS server providing the file.
error.nulinteger Specifies an object that is used to output any error code generated during the execution of the method. This parameter must be an object, not an integer value. If error is not specified or is .nul and errortext is not specified or is .nul then any error that occurs during object creation will halt the program. If an error object or errortext object is specified and an error occurs during execution then the error code or text is output into that object and the method returns .nul.
errortext.nulstring Specifies an object that is used to output any error text generated during the execution of the method. This parameter must be an object, not a string value. If error is not specified or is .nul and errortext is not specified or is .nul then any error that occurs during object creation will halt the program. If an error object or errortext object is specified and an error occurs during execution then the error code or text is output into that object and the method returns .nul.
retry1000000integer The number of microseconds between retries, if the operation is not successful immediately.
timeout5000000integer The number of microseconds allowed for the operation to complete before it is assumed that it will fail.
recordidfieldname.nulstring

The name to use for the exposed internal unique record ID. If this is supplied then the internal record ID will be shown as an indexed unique field. The internal record id is read-only and guaranteed for the life of the record in the table. If the table is reorganized, the record ID is likely to change.

[Warning]Warning

Do not store the record ID for future use! The record ID will certainly change if the table is reorganized so it should not be used for any long term purpose. Within the same session and assuming the same database table it can be used for safely reselecting the same record, which makes it an excellent candidate for routines that search for duplicate records and such.

settxfactor()

Description

Sets the transmission factor. This is used to moderate the speed at which the packets are transmitted. A factor of 0 means that the packets will be sent at the maximum speed (this may be too fast for Internet connectivity and result in difficulty reading data and excessive retries and timeouts).

Prototype

ppcstype1var.settxfactor ( integer txfactor )

Parameters
ParameterDefault valueType nameDescription
txfactorNoneinteger The factor to use to delay the server. The value 0 means no delay and the higher the number the longer the delay will become. Also each increment is a greater delay than the one before, so a setting of 3 is slower by a greater amount than just the total of the delay at 1 plus 2.