OPEN Verb - Open File BBj

For this topic's original documentation, see OPEN Verb - Open File.

BBj-Specific Information

Syntax

OPEN (channelno{,MODE=string}{,TIM-int}{,ERR=lineref})alias

Description

In BBj 13.0 and above, the TIM=int option can be used to override the default timeout value (10 seconds).

BBj supports third party 'plugin' file types. The developer can define a new file type by writing Java classes that implement the interfaces com.basis.plugin.FilePlugin and com.basis.plugin.FileOpenPlugin. For more information, see Java API for BBj.

If the user has written the following Java classes:

com.userFileType implements FilePlugin
com.userFileTypeOpen implements FileOpenPlugin

and has defined the following alias in the current config.bbx file:

alias J0 com.userFileTypeOpen

then the new file type may be opened using the following syntax:

OPEN (channelno{,MODE=string}{,ERR=lineref})"J0"

All READs and WRITEs to the channel will then be delegated to the Java code in com.userFileType.

For further plugin code samples, go to <bbj install dir>/demos/plugins, or see BBj Filesystem Plugin.

For additional information about opening a printer, see Printing in BBj.

NOTE: In BBj, using ISZ= does not automatically LOCK a file. If the file needs to be locked then use the LOCK verb

NOTE: In PRO/5 15.01 and higher, and BBj 15.10 and higher, the OPEN verb by default is restricted from opening pipes (commands starting with "<", ">", or "|") in console mode.  This is to protect against accidentally overwriting a data file as a side effect of inadvertently specifying a pipe expression.  To open a pipe at the console, set SETOPTS byte 9 bit $10$ or include MODE="PIPE" in the OPEN.


Mode

Value

Description

CRYPTALG=

AES-128

AES-256

Uses AES-128 bit encryption, which is also the default.

In BBj 6.0 and higher, and PRO/5 6.0 and higher, uses AES-256 bit encryption.

FOCUSDELAY=

Seconds

Specifies the timeout value for 'FOCUS' (default is 10 seconds)

BBj-Specific MODE Options

SYSGUI Mode

Description

ANTIALIASED=[ON|OFF]

In BBj 5.0 and higher, enables and disables font-enhancement technology, which makes screen fonts appear smoother and clearer on some displays. The default setting is ON (enabled). If this mode is set to OFF, then the default font-enhancement technology employed by the operating system will be used instead (e.g. ClearType on MS Windows).

DPI=<integer>

Sets the effective DPI of the SYSGUI channel. BBj uses the effective DPI to calculate the number of pixels used for a given font size. The default value for the effective DPI is 96. Specifying a value of 0 instructs BBj to use the native DPI as reported by the OS. Increasing the value will increase the number of pixels used for a given font size, making the font glyphs larger. Conversely, decreasing the value will decrease the number of pixels used for a given font size, making the font glyphs smaller.

File Mode

Description

TRIGGER

Only valid when opening a file from inside a file trigger. This option tells BBj to open a channel to the same open file handle that fired the trigger. This makes it possible to change the current position in the file that fired that trigger, from within the trigger. This also tells BBj to leave the actual file handle that fired the trigger, open after executing the trigger code.

Example 1

Open a channel that READ/WRITEs to the Windows Registry:

REM Demo using the Registry plugin. This plugin is Windows specific as it
REM opens/reads/writes/creates registry keys and values.

REM Assume the following aliases in the config.bbx file:
REM ALIAS J1A com.basis.plugin.RegOpenPlugin "SOFTWARE\\BASIS"
REM ALIAS J1B com.basis.plugin.RegOpenPlugin "SOFTWARE\\BASIS\\TESTKEY"

LET chan = UNT

REM Open the registry key using the plugin.
OPEN(chan,mode="key=HKEY_LOCAL_MACHINE,access=KEY_CREATE_SUB_KEY")"J1A"

REM Write a value for the registry key
WRITE RECORD(chan,key="TESTKEY")"This should be a subkey"

REM CLOSE the registry key.
CLOSE(chan)

REM Open the registry key using the plugin.
OPEN(chan,mode="key=HKEY_LOCAL_MACHINE,access=KEY_WRITE")"J1B"

REM Write a value for the registry key
WRITE RECORD(chan,key="TESTVALUE")"This is registry test"

REM CLOSE the registry key.
CLOSE(chan)

REM Open the registry key using the plugin.
OPEN(chan,mode="key=HKEY_LOCAL_MACHINE,access=KEY_READ")"J1B"

REM Read a value of a registry key
READ RECORD(chan,key="TESTVALUE")RECORD$

REM PRINT out the registry value.
PRINT "HKEY_LOCAL_MACHINE/SOFTWARE/BASIS/TESTKEY = " + RECORD$

REM CLOSE the registry key.
CLOSE(chan)

REM Open the registry key using the plugin.
OPEN(chan,mode="key=HKEY_LOCAL_MACHINE,access=KEY_SET_VALUE")"J1B"

REM Remove the registry value
REMOVE(chan,key="TESTVALUE")

REM CLOSE the registry key.
CLOSE(chan)

REM Open the registry key using the plugin.
OPEN(chan,mode="key=HKEY_LOCAL_MACHINE,access=KEY_ALL_ACCESS")"J1A"

REM Remove the registry key
REMOVE(chan,key="TESTKEY")

REM CLOSE the registry key.
CLOSE (chan)

Example 2

Open a channel that READ/WRITEs to a simple Hashmap:

REM This simple plugin stores key/value pairs in a in-memory Hashmap
REM Assumes the following alias in the config.bbx file:
REM ALIAS J2 com.basis.plugin.HashOpenPlugin

OPEN (22)"J2"
WRITE (22,KEY="10")"October"
READ (22,KEY="10")A$
PRINT A$

See Also

Devices Under the UNIX Operating System

Verbs - Alphabetical Listing



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.