OPEN Verb - Open File BBj

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

BBj-Specific Information

Syntax

OPEN (channelno{,MODE=string}{,ISZ=num}{,TIM=int}{,ERR=lineref}) fileid

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