# Case Insensitive Overview

Updated: 10/19/2020, 10:24:56 AM
Created: 10/19/2020, 10:24:56 AM
Last Updated By: Daniel Klein
Read Time: 10 minute(s)

# Create Case Sensitivity Control

Because jBASE already has many customers who rely on their applications running as they currently do we have the ability to switch any new behavior on and off.

Within jBASE there is a config file that lets users tailor how jBASE behaves. Although many of the changes are aimed at supporting case sensitivity, much of the new behavior is generic enough to be of use to existing users. A good example is that jQL verbs no longer have to be all upper case.

To enable this behavior you would to simply set case_insensitive_queries = true in the Config_EMULATE configuration file.

New config flags currently are:

  • case_insensitive_md = true - Ignore the case of commands entered in a jShell
  • case_insensitive_file_ids = true - Ignore the case of file names
  • case_insensitive_queries = true - Ignore the case of jQL syntax
  • case_insensitive_runtime_strings = true - Ignore the case of strings in jBC and jQL

These are described in more detail below.

# jBASE Executables (jSH only)

When running in a jShell, all jBASE commands can be accessed in any case, this behavior can be controlled by setting case_insensitive_md = true.

For example to run jdiag from within a jsh you should now be able to do:

  • jDIAG jdiag JDIag

However this new behavior does not extend to your application program names and things outside of jBASE, like UNIX/Windows commands and C functions which are still case sensitive.

# jBC

jBASE BASIC has been changed in the following area's.

# Basic Source Code

New utility: jFormatCode

Format existing code jFormatCode -f myfile source_name.b
Reformat older code so it can be compiled in jBASE jFormatCode -p -f myfile source_name.b
Get some help jFormatCode -?

Code reformatting follows the these simple rules

  • Reserved words are converted to UPPERCASE.
  • Strings and comments are ignored.
  • Everything else, i.e. variables, statement labels, function and subroutine names, are converted to lowercase.

This is intended for use when porting source into jBASE, the idea being simply that if everything has been through the same process then renaming variables and subroutines should not be an issue.

A good example to consider is that in some implementations of PICK, variables can be in any case, e.g.

abc = 1 Abc = 2 ABC = 3

Within jBASE you would end up with 3 versions of [abc]. After conversion, all instances of abc will be in the same case so jBASE will now work as expected. This will also apply to subroutine names, arrays and COMMON. It will also try and fix common issues like reserved words being used as variables, no spaces after GOTO, etc...

However it is not necessary to change anything. For example, if you want leave the source code as it is then the BASIC command as a new option (T) that will translate the code on-the-fly during the compilation stage.

BASIC myfile source_name.b (T
1

There is no emulation option to control this, it is always available regardless of which emulation options are / are not set. IOW, you can use the (T) option or jFormatCode at any time.

There is also a 't' option in the jed editor, e.g.

  • fibct

will 'fi'le, 'b'asic, 'c'atalog and call the code 't'ranslator.

# Runtime Strings (String comparison within a jBC process and jQL)

At first glance this will look pretty straight forward, as you could do something like:

  • my_id = "abc" then
  • if my_id = "ABC" then

With case sensitivity enabled the case of a string should not matter, abc is ABC. In jBASE currently, case does matter, it uses standard C libraries for pattern matching, in-fact for almost everything.

To get around this issue, whenever a string is assigned, an upper case version of the string is also created. This version is used for all pattern matching, however when strings are to be displayed we use the original version.

A simple example in jBASE could be as follows:

name = "Corwin"
LOCATE name IN employees SETTING pos THEN
   PRINT "found employee", name
1
2
3

When looking for "Corwin" in the list of names, we use "CORWIN", the list of names will also be in upper case so if it's in there we can easily find it. This additional version of the string should only be generated once and should have minimal impact on performance. Once enabled this behavior should be global, jQL should also behave the same way. This new behavior is controlled with the case_insensitive_runtime_strings emulation option.

# Files

# Filename case

All files listed on JEDIFILEPATH get added to an internal lookup, although this may seem like overkill. Internally, whenever you try to open a file, jBASE will search all locations listed on JEDIFILEPATH until it opens the requested file. This will happen for every OPEN. Because the cacheing of filenames is only done when a new jBASE process starts, for most processes it should end up being a little more efficient as the internal cache of available files is also used by all child processes.

Typically, most users may start by opening a jShell or some form of menu, any new processes started will always check cached names first.

There are exceptions, things like a new file is created by another user. In these cases, files are opened using the existing mechanisms and the cache is updated.

This new behavior is controlled with the case_insensitive_file_ids emulation option.

# Record ids

All files should now support case-less record IDs. For example,

READ data FROM file, "abc" ELSE NULL
READ data FROM file, “ABC” ELSE NULL
1
2

should return the same record.

In order to be able to work with case insensitive record IDs, the file needs to be created as case insensitive via the CASE=NO option of CREATE-FILE.

If necessary, jrf can be used to revise the case-sensitivity of an existing file.

You can list which files currently support casing via LISTF.

FILENAME.................................... TYPE   MODULO  SEP  BCKUP  INSENSITIVE  CRYPT

&SAVEDLISTS&]D                                 JD        1    1    yes          no    no
 &SAVEDLISTS&                                 DIR                  yes          no    no
CURRENCY-TABLE]D                               JD        1    1    yes          no    no
 CURRENCY-TABLE                                JD        1    1    yes          no    no
CUSTOMER]D                                     JD        1    1    yes          no    no
 CUSTOMER                                      JD       16    1    yes          no    no
DEMOFILE]D                                     JD        1    1    yes         yes    no
 DEMOFILE                                      JD        1    1    yes         yes    no
INVENTORY]D                                    JD        1    1    yes          no    no
 INVENTORY                                     JD        1    1    yes          no    no
MD]D                                           J4       11    1    yes          no    no
ORDERS]D                                       JD        1    1    yes          no    no
 ORDERS                                        JD       32    1    yes          no    no
PARTS]D                                        JD        1    1    yes          no    no
 PARTS                                         JD        1    1    yes          no    no
PGM]D                                          J4        3    1    yes          no    no
 PGM                                          DIR                  yes          no    no
PGM]MOBJECT                                    JD        1    1    yes          no    no
SALES]D                                        JD        1    1    yes          no    no
 SALES                                         JD        1    1    yes          no    no
bin                                           DIR                  yes          no    no
lib                                           DIR                  yes          no    no
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Any files that support casing will be shown in the INSENSITIVE column.

# jQL

# Queries and Verbs

All jQL statements and verbs should now work in any case. The following 2 jQL statements will function identically with no need to create redundant dictionary records:

list myfile with account_balance gt "0" firstname lastname account_balance
LIST MYFILE WITH ACCOUNT_BALANCE GT "0" FIRSTNAME LASTNAME ACCOUNMT_BALANCE
1
2

Commands, verbs and dictionary's should be usable in any case. This behavior is controlled with the case_insensitive_queries emulation option. Note that case_insensitive_file_ids must also be set in order for the file name to be used in a case independent manner.

Setting the case_insensitive_runtime_strings emulation option will cause string comparisons to be case independent. For example, the following 2 jQL statements should list the same records:

list myfile lastname WITH with lastname = 'smith'
list myfile lastname WITH with lastname = 'SMITH'
1
2

# Dictionary Items

Fields within the dictionary items are not yet full implemented. Attribute 1 and many conversions have been addressed and some formats currently work.

# New commands

# config-strings

This command displays the emulation options for a given emulation, the current emulation being the default if not specified.

cmd:           config-strings
Description:   Displays jBASE Config_EMULATE settings.
Usage:         config-strings {options}
               config-strings -h | -help | -?

Options:
   -a -all, display all configuration options indicating which ones
            are set and which are unassigned.
   -c -compact, display in compact format: key = value
   -e -emulation <<mode>>, display section for emulation <<mode>>
   -j{n} -json{n}, output is in JSON, where "n" specifies the JSON format.
                   Refer to the documentation for the $tojson() method.
                   This option produces an object with two embedded objects:
                      "header", e.g.
                           {
                               "emulation":"jbase",
                               "system":"athens",
                               "date":"06 feb 2019",
                               "time":"15:24:52",
                               "user":"theaetetus"
                           },
                       "emulation" is an object with the emulation settings
   -l -list,  list sections in config_EMULATE
   [email protected], display @ values

Examples:
   config-strings           display current emulation settings.
   config-strings -j        display current emulation settings, output as JSON
   config-strings -a        display all configuration settings
   config-strings -a -j1    display all settings, output as JSON and is formatted
   config-strings -e prime  display settings for the prime emulation
   config-strings -e d3 [email protected]  display settings and @ values for the d3 emulation
   config-strings -l        list sections in Config_EMULATE.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

# jFormatCode

This command reformats and parses jBC (BASIC) code to conform to the jBASE compiler.

cmd:     jFormatCode
desc:    formats existing code and ports BASIC code to jBASE.
usage:   jFormatCode filename
options: -file, -tabs, -parse, -diffs, -pause -replace, -quiet, -stamp, -confirm, -no_backup, -no_line_numbers, LPTR, -help

where:   -f -file, name of the file to read source from, default [.].
            -file /home/data/bp
         -t -tabs, number of spaces to pad and indent formatted source.
            -tabs 2,2
         -p -parse, call pre-parser to force code to conform to the jBASE compiler.
         -d -diffs, display line by line comparison of source during pre-parser.
         -pg pause output for each page. (q to quit)
         -r -replace, Overwrite original source with parsed source.
         -q -quiet, dont output source to screen.
         -s -stamp, add a time stamp to end of source.
         -c -confirm, dont ask if you really want to replace the file.
         -n -no_backup, dont create a backup of original version.
         -l -no_line_numbers, dont display line numbers in preview.
         LPTR, send to printer. (must be on end)
         -?, -h, -help, this page.

e.g:     jFormatCode -file /home/account1 -quiet -replace -no_backup my_prog.b
         jFormatCode my_prog.b LPTR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# CASE

New command to control case sensitivity at runtime.

One issue within jBASE is that some commands and functions will behave differently if strings are case insensitive. It may be that 99% of the time its not an issue but when it is you can do:

To disable:

CASE OFF
1

after issuing command case sensitivity will be disabled.

To enable it again simply do:

CASE ON
1

# Updated Commands

LISTF Changed to support case sensitive files.
jchmod Changed to support case sensitive files.
BASIC Changed to allow code formatting at runtime.
jcompile Changed to allow code formatting at runtime.

# New jBC statements

# CASING

Just like the new CASE command, within a jBC program you may need to disable case insensitivity. This new jBC statement will simply disable case_insensitive_runtime_strings from within a jBC program, e.g.

x = 'HELLO'
CASING ON
IF x = 'hello' THEN CRT 'match' ELSE CRT 'no match'
CASING OFF
IF x = 'hello' THEN CRT 'match' ELSE CRT 'no match'
1
2
3
4
5

Program output:

no match
match
1
2

# Miscellaneous

For new users to jBASE there is now Pick style command stack in the jShell, .L, .X, .C.

Just enough to help with the transition.

Back to Miscellaneous