Frequently Asked Questions - Programs
Contiguous, Formatted, Indexed-Contiguous, and text files may be exclusively opened using the EOPEN statement ('EOPN #1,"filename"') or the "E" open access mode ('OPEN #1, "filename"'). For compatibility with UniBasic, an exclusive open of a text file or non-Universal UniBasic file will succeed if another user has already opened the file in shared mode as long as the file has not been opened by another user in exclusive mode. An error will occur if a Portable or Universal file is opened in exclusive mode and another user has the file open in either shared or exclusive mode.
The commands PSAVE and OEM support program protection.
This error can occur if the program was created using a later version of dL4. Usually, this will only happen if the program uses a feature of that later dL4 version which is not supported in the local copy of dL4.
The commands "WB" and "WT" in the SCOPE debugger move the debugger window to the bottom ("WB") or the top ("WT") of the screen. The "WINDOW" command can also be used to move the debugger window. Note that, in dL4 for Unix, a debugger window is only used if dL4 windows are open.
The commands "WF", "WH", and "WS" in the SCOPE debugger resize the height of the debugger window. The commands set the debugger window to the full ("WF") height, one half ("WH") height, or a quarter ("WS") height of the full screen, The debugger WINDOW command accepts a single numeric parameter to set the number of lines in the window (the command "WINDOW 6" or "W6" would select a height of 6 lines).
PORT mode 4 returns the name of the program running on a port.
The msc$(7) returns the hot-key character used to start a SWAP program.
Back to dL4 FAQ's
The runtime parameters are set in the Windows Registry setting keys HKEY_CURRENT_USER\Software\DynamicConcepts\dL4\Environment or HKEY_LOCAL_MACHINES\Software\DynamicConcepts\dL4\Environment.
Please refer to dL4 Installation & Configuration Guide for Windows 95/NT for details
This error is reported if the ISAMFILES runtime parameter value is set too small.
This error is reported if the ISAMFILES runtime parameter value is set too small.
A BASIC error 97 indicates an unexpected error status returned by system call. The error message returned by msc$(2) will display Unix or Windows system error number when an error 97 occurs.
The msc$(2) built-in function returns the full text of the last error message. For some errors, such as "ISAMFILES value too small", the error message will include c-tree specific error information.
Tables can be created using the normal Full-ISAM procedure of BUILDing a "file", defining the record structure, and adding indexes.
The Microsoft SQL Full-ISAM driver (included in dL4 for Windows) and the MySQL Full-ISAM driver use a special filename format, server:database.owner.table. The server and owner fields are optional. The driver also supports "user=" and "pswd=" options to specify the server login and password values. The following are examples of opening tables.
Open #3,"bigsystem:accounting.payroll" As "Microsoft SQL Server Full-ISAM"
Open #3, "(user=fred, pswd=secret)xyz:sales.customer" As "Microsoft SQL Server Full-ISAM"
Open #3,"server:accounting.payroll" As "MySQL Full-ISAM"
The "-u" option can be used on the DUMP command to display line numbers in any program ("dump -u filename").
All date and time related functions are year 2000 compliant in dL4.
The CLOSE macro in the user?s Terminal Definition File (TDF) can be defined to output any string of characters when dL4 exits.
Protected fields are printed in dimmed mode. If, however, the characters are already in a dark color, the driver will display the field in a bright color to contrast protected with unprotected characters. Therefore, a protected field appears in a bright color if a dark color is used in the protected field. The following sample program demonstrates how to display a protected field in bright blue in dL4 for Windows.
10 Print '255FONTCOLOR BP';"Protected Field";'EP FM', ! dimmed bright blue
20 Print '128FONTCOLOR BP';"Protected Field";'EP FM'; ! dimmed dark blue
The FONTCOLOR and the BACKCOLOR mnemonics set the foreground text and background colors, respectively. They take RGB color values to set appropriate color. The following statements provide examples for both FONTCOLOR and BACKCOLOR.
| Print '0 BACKCOLOR 255FONTCOLOR' | ! black background, blue foreground |
| Print '65280 FONTCOLOR 255 BACKCOLOR' | ! green foreground, blue background |
The following program sets the background and foreground borders and default colors to blue and yellow, respectively.
| Open #1,{"","titl,hide",40,10} As "Window" | ! Hidden Window |
| Print #1;'255Backcolor cs ye'; | ! set border and default colors |
| Channel 11,#1; | ! make window visible |
After the Channel statement, the current foreground and background colors may be changed to desired colors without affecting the border colors.
No, dL4 programs binaries are fully compatible. In other words, programs SAVEd under a UNIX system will run on a Windows system, and vice versa. However, if the programs use system specific operations, then the programs will not be portable and errors may occur during execution. For example, the following would make a program specific to the UNIX operating system:
system("ls")
SCOPE treats its command line arguments as an initial command. Thus, a dL4 program can be initiated by executing the following commands from a user's .profile file in the UNIX environment or from autoexec.bat file in the Windows environment, respectively.
start scopew "program to start" |
A dL4 structure variable consists of a collection of one or many different data types which are defined in a structure template. The BASIC interpreter must know about these data types when a structure variable is defined or referenced. This information must be available when a program is saved so that errors can be detected at SAVE time, which is much faster than at run time.
In addition to LUMAP and DL4LUST, dL4 uses the LIBSTRING runtime parameter to locate programs and libraries. It is a runtime parameter which contains a space separated list of directories to search when linking, CALLing, or CHAINing to program files. This value is returned by the debugger's STATUS UNIT command and by the Msc$(6) function. The OPEN statement does not use LIBSTRING to find data files.
Please refer to the appropriate Installation and Configuration manual for a discussion on configuring LIBSTRING.
Related Article: September, 1997 Technical News
An attempt is first made using the LUMAP runtime parameter which maps relative file paths to absolute file paths. If the program path cannot be translated by LUMAP, then dL4 uses the LIBSTRING runtime parameter to locate programs and libraries. Finally, dL4 uses the DL4LUST runtime parameter. LIBSTRING contains a space separated list of directories to search when linking, CALLing, or CHAINing to program files. This value is returned by the debugger's STATUS UNIT command and by the Msc$(6) function. DL4LUST is similar to LIBSTRING, but it is used for both program and data files. The OPEN statement does not use LIBSTRING to find data files.
Please refer to the appropriate Installation and Configuration manual for a discussion on configuring LIBSTRING.
Related Articles: June, 1997 Technical News , September, 1997 Technical News
The output of a DOS command will remain on your screen if you start command.com from scope and then initiate the DOS command. For example, the following will cause the output of dir to remain on the screen.
#cmd.exe
C:>dir
There are two types of programs under Windows, namely, console programs and graphical programs. dL4 for Windows (scopew) is a graphical program and hence a separate console windows must be opened for console programs. That console window is closed as soon as the command is completed. The SYSTEM 30 statement can be used to execute a command in a hidden window.
The dir command is not a separate program, it is part of cmd.exe (or command.com on older systems). The proper syntax to execute a dir command would be "SYSTEM command.com /c dir". The directory driver should be used instead of the "dir" command for maximum portability. The following program displays all filenames in current directory.
|
10
|
Dim r$[100] |
|
20
|
Open #0,"." As "directory" |
|
30
|
Do |
| 40 | Read #0;r$ |
| 50 | If r$ = "" End |
| 60 | Print r$ |
| 70 | Loop |
| 80 | End |
A file system restore, or a cpio -a option may invalidate Software license. In addition, passport daemon prior to release 3.5 on SCO OpenServer 5 can invalidate Software license.
A new license and a new SSN are required to recover from this problem. Another solution is to use a hardware passport which does not suffer from any of the above problems.
The intrinsic CALLs GetRegistry and SetRegistry can be used to read or write registry values.
Back to dL4 FAQ's
Program cache is intended for multi-user systems and so it is available only on dL4 for Unix. A local, non-shared cache can be created for each dL4 for Windows process by setting the DL4LOCALCACHE runtime parameter to the desired cache size in bytes. This local cache is not aware of program changes made by other dL4 processes and should not be used during program development.
Program cache uses Unix semaphores and shared memory. The Unix system must be configured to support one semaphore per cache and to support shared memory of the desired size. Please refer to your Unix manual for semaphore and shared memory configuration.
Related Article: Program Cache
Program cache is used to share a single memory image of a program or library between different processes. It is available only on dL4 for Unix, version 3.1 or later. The environment variable "DL4CACHE" must be set in order to use program caching. The value of DL4CACHE is a file specification of the form " [blocks:blocksize] name". The following example specifies a global cache of 8 megabytes:
More dL4 FAQs: Programs | Terminal/Printers
The operating system must be configured to support both shared memory and semaphores.
Related Article: Program Cache
This can be achieved by changing the Windows Rows to the appropriate value in the Preferences » Initial Values setting for scopew and then restarting dL4.
There are two solutions to this issue. The first solution is to set and export the LINES environment variable. The LINES environment variable always overrides any default setting in the Terminal Definition File.
The second solution is to change {24}%SR to {50}%SR in the Init line in the OutputMacros section in the Terminal Definition File.
This can be achieved by changing the Windows Columns to the appropriate value in the Preferences » Initial Values setting for scopew and then restarting dL4.
There are two solutions to this issue. The first solution is to set and export the COLS environment variable. The COLS environment variable always overrides any default setting in the Terminal Definition File.
The second solution is to change {80}%SC to {132}%SC in the Init line in the OutputMacros section in the Terminal Definition File.
The special record number -4 can be used to output to the end of the file. For example, the statement
Print #5,-4;"Append this text"
would add the line "Append this text" to the end of the text file open on channel 5.
Linux normally uses the BASH shell and environment variables should be set in the .bash_profile file in the user HOME directory instead of .profile.
The ub2dl4 utility package provides a simple way to convert uniBasic programs to dL4. Installation and use of the current release are described in the readme.txt file. The ub2dl4 package can be downloaded from the Download Center on http://wwww.unibasic.com or from the /dist/pub/FF/ub2dl4 directory on ftp.dynamic.com (check the directory for the latest version).
