Goto: 4C Home | 4C Docs | System PCLs List sys.open_ldata()

sys.open_ldata()

Purpose:
sys.open_ldata() opens a connection to linked data.
Usage:
ret = sys.open_ldata(<ldname>,<ldkey>,<field>,<flags>[,<opt> ...]);
Arguments:

<ldname> - an alpha var that can be used in subsequent calls to. sys.get_ldata() , sys.set_ldata() , and sys.close_ldata()

<ldkey> - The key to the s_ldatah file.

<field> - Any type of field. This is the field in the 4C application that will be used for importing and exporting the data. When data is imported, this field will have the value of the imported data. When exporting data, the value in this field is formatted and exported to the external application.

<flags> - can be combinations of:

<opts> - Alpha vars of the form "App=<app>" Multiple opts can be specified together by separating different options with a comma. Ex. "App=<app>,Topic=<topic>". The last 12 parameters can all be used for specifying these options.
Returns:
0 - Success.
-1 = Failure and sys.errno will be set.
Where Used:
sys.open_ldata() can be called from anywhere. For system wide LData connections that need to stay open, you will probably want to start this in a daemon process.
Example:
There is a program in the bootstrap directory that you can look at to see how a connection to a spreadsheet may be set up. The program ldata.tst.1 links 10 different SysScratch 4c fields to 10 different cells in the spreadsheet /test/xx.xls. It uses the "testdde" record in the s_ldatah fileh. If you use this example, you will need to modify at least, the sldh_server and sldh_topic fields for the "testdde" rcd.
Description:
Use sys.open_ldata() to open LData connections with external processes. The LData connection will remain open for as long as <field> is in memory. If it is not in a SysScratch file, and the program that has this field in memory exits, then the LData connection is closed automatically. Onetime LData links are automatically closed after the sys.open_ldata() call. You can explicitly close an open LData connection using sys.close_ldata()
Bugs/Features/Comments:
You cannot specify more than one item/field in a sys.open_ldata() call. This makes startup of a connection with many items slow. If this is a problem, I will look for a way around it.
See Also:
sys.get_ldata()
sys.set_ldata()
sys.close_ldata()


Back to Top