Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

jBase: listing of files and verbs in jBasic

137 views
Skip to first unread message

Mike Yates

unread,
Oct 18, 2024, 10:35:05 AM10/18/24
to Pick and MultiValue Databases
I am trying to port my "Pick Explorer" to jBase.
There seem to be no "F" or "V" types in MD.
I can list files by parsing "EXECUTE 'ls' RETURNING SLIST" but how can I list verbs?"
LISTF is very complicated to parse. It is easier to append "Q" type MD items to SLIST, just as I could append "PQ" type items to a list of system verbs (and cataloged custom verbs).

Mike Yates

unread,
Oct 18, 2024, 11:33:38 AM10/18/24
to Pick and MultiValue Databases
I've found this method:-
001 LIST = ''
002 * EXECUTE "echo $JBCRELEASEDIR" CAPTURING RELDIR
003 RELDIR = '/opt/jbase/5.9.0'
004 EXECUTE 'ls ':RELDIR:'/bin' CAPTURING SLIST
005 FOR L = 1 TO DCOUNT(SLIST,@AM)
006   IF INDEX(SLIST<L>,'.',1) = 0  THEN LIST<-1> = SLIST<L>
007 NEXT L

but how do I get line 2 working? It returns the variable name, instead of the contents which you get in TCL.

Jim Idle

unread,
Oct 18, 2024, 11:42:48 AM10/18/24
to mvd...@googlegroups.com
You can use the JQL primitives in BASIC. But there are no verbs. The MD/VOC is really just a convenience if you don't want to adapt existing code.

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mvdbms/d9f0c739-8798-4f4e-a7cc-a20b5e7e380fn%40googlegroups.com.

bdeck...@gmail.com

unread,
Oct 18, 2024, 12:09:09 PM10/18/24
to mvd...@googlegroups.com

IF GETENV(\JBCRELEASEDIR\,JBCRELEASEDIR) THEN

    CRT \JBCRELEASEDIR=\:JBCRELEASEDIR

END

 

Result:

jsh JBASEADM ~ -->TEST

JBCRELEASEDIR=C:\jBASE\6.1.2

jsh JBASEADM ~ -->

--

Mike Yates

unread,
Oct 18, 2024, 12:09:55 PM10/18/24
to Pick and MultiValue Databases
Yes the primitives work in jBASIC EXECUTE, but so do OS shell commands (e.g. "ls"), except "echo $VAR" 
How do you list CONFIG options within jBasic?
I am only trying to emulate original Pick.

bdeck...@gmail.com

unread,
Oct 18, 2024, 12:11:53 PM10/18/24
to mvd...@googlegroups.com

myOsCommand = \echo whatever\

EXECUTE @IM:\k\:myOsCommand

 

From: mvd...@googlegroups.com <mvd...@googlegroups.com> On Behalf Of Mike Yates


Sent: Friday, October 18, 2024 10:10 AM
To: Pick and MultiValue Databases <mvd...@googlegroups.com>

bdeck...@gmail.com

unread,
Oct 18, 2024, 12:16:31 PM10/18/24
to mvd...@googlegroups.com

An EXECUTE without the os shell escape (prefix @AM:\k\) will cause the command to be executed by the jsh (TCL) not by the OS shell.

Therefore, shell expansions like $ would not work, because jsh doesn’t do that.

Once you prefix the command with the shell escape (like universe’s sh -c, or D3’s !), it will work.

 

But I’d use the inbuilt GETENV function if all you’re trying to do is to get the value of an env variable.

 

Best,

Bruce

bdeck...@gmail.com

unread,
Oct 18, 2024, 12:23:38 PM10/18/24
to mvd...@googlegroups.com

Remember too that depending on the release of jBASE, and the way the user has configured preferences, you might see things in /bin you might want to ignore.

For example, on Windows, each verb may end in .exe (e.g. sort.exe), because jBASE exposes all the verbs as actual O/S binaries (executables).

Also, for efficiency, depending on the release you’re on, jBASE may also produce a shared library version of that command.  For example, on Windows you’ll see  sort.exe and a sort.dll).

On linux, you may find both a sort and sort.so (shared object).

Just mentioning because you may want to structure your loop to filter out the extensions and dups to make it work on all jBASE systems, regardless of release or customer configuration.

 

Bruce Decker

 

Sent: Friday, October 18, 2024 10:12 AM
To: mvd...@googlegroups.com

Mike Yates

unread,
Oct 18, 2024, 12:37:38 PM10/18/24
to Pick and MultiValue Databases
Thanks, bdeck, but meanwhile I found "config-strings" which will be useful in other ways in "Pick Explorer":-

    TST1
001 LIST = ''
002 EXECUTE 'config-strings -@' CAPTURING CSTRINGS
003 RELDIR = OCONV(CSTRINGS<1>,'G1:1')

004 EXECUTE 'ls ':RELDIR:'/bin' CAPTURING SLIST
005 FOR L = 1 TO DCOUNT(SLIST,@AM)
006   IF INDEX(SLIST<L>,'.',1) = 0  THEN LIST<-1> = SLIST<L>; PRINT SLIST<L>

bdeck...@gmail.com

unread,
Oct 18, 2024, 1:10:46 PM10/18/24
to mvd...@googlegroups.com

It is very useful indeed.  If you need to support older releases of jBASE, just verify that some of these capabilities were in the older release.  For example, here’s a slick way to get a list of files in jBASE using jBASE dynamic objects and inbuild class/methods:

 

$option jabba                     ; * enable object oriented basic

equ beautify to 5

mySystem = new object("$system")  ; * instantiate system object

mySystem->getfiles()              ; * use getfiles method of system object

crt mySystem->$tojson(beautify)   ; * convert file list to json with tojson inbuilt method.

 

And the output would look like this:

 

jsh JBASEADM ~ -->GETFILES

{

    "filepath":[

        "C:\\jBASE\\JBASEADM\\MD]D",

        "C:\\jBASE\\JBASEADM",

        "."

    ],

    "files":[

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\MD]D",

            "directory":"C:\\jBASE\\JBASEADM\\MD]D",

            "name":"MD",

            "index":0

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\MD]D",

            "directory":"C:\\jBASE\\JBASEADM\\MD]D",

            "name":"MD",

            "index":0

        },

        {

            "fullpath":"C:\\jBASE\\SYSTEM]D",

            "directory":"C:\\jBASE\\JBASEADM\\MD]D",

            "name":"SYSTEM",

            "index":0

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\bin",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"bin",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\BP",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"BP",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\BP]D",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"BP]D",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\BP]MOBJECT",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"BP]MOBJECT",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\lib",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"lib",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\MD]D",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"MD]D",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\PROC",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"PROC",

            "index":1

        },

        {

            "fullpath":"C:\\jBASE\\JBASEADM\\PROC]D",

            "directory":"C:\\jBASE\\JBASEADM",

            "name":"PROC]D",

            "index":1

        },

        {

            "fullpath":".\\bin",

            "directory":".",

            "name":"bin",

            "index":2

        },

        {

            "fullpath":".\\BP",

            "directory":".",

            "name":"BP",

            "index":2

        },

        {

            "fullpath":".\\BP]D",

            "directory":".",

            "name":"BP]D",

            "index":2

        },

        {

            "fullpath":".\\BP]MOBJECT",

            "directory":".",

            "name":"BP]MOBJECT",

            "index":2

        },

        {

            "fullpath":".\\lib",

            "directory":".",

            "name":"lib",

            "index":2

        },

        {

            "fullpath":".\\MD]D",

            "directory":".",

            "name":"MD]D",

            "index":2

        },

        {

            "fullpath":".\\PROC",

            "directory":".",

            "name":"PROC",

            "index":2

        },

        {

            "fullpath":".\\PROC]D",

            "directory":".",

            "name":"PROC]D",

            "index":2

        }

    ]

}

 

You just want to be sure your target audience is on a later release of jBASE where all of these goodies are available.

 

Best,

Bruce

 

 

 

From: mvd...@googlegroups.com <mvd...@googlegroups.com> On Behalf Of Mike Yates
Sent: Friday, October 18, 2024 10:38 AM
To: Pick and MultiValue Databases <mvd...@googlegroups.com>
Subject: Re: [mvdbms] Re: jBase: listing of files and verbs in jBasic

 

Thanks, bdeck, but meanwhile I found "config-strings" which will be useful in other ways in "Pick Explorer":-

Wols Lists

unread,
Oct 18, 2024, 1:27:59 PM10/18/24
to mvd...@googlegroups.com
On 18/10/2024 17:09, Mike Yates wrote:
> Yes the primitives work in jBASIC EXECUTE, but so do OS shell commands
> (e.g. "ls"), except "echo $VAR"
> How do you list CONFIG options within jBasic?

> I am only trying to emulate original Pick.

Jim obviously knows a heck of a lot more than I do, but I wouldn't have
thought jBase was the best version to emulate Pick in.

jBase was written to compile basic programs to OS executables. As such
the idea of running them from TCL doesn't make sense. Nor does having an
MD/VOC.

Seeing as QM started as a similar idea (it started life as a library, if
you read the history), there's no reason jBase couldn't have had a TCL
shell added, but from what I've *heard* about jBase the concept feels a
bit of an alien bolt-on.

Cheers,
Wol

Bruce Decker

unread,
Oct 18, 2024, 2:19:59 PM10/18/24
to Pick and MultiValue Databases
All commands, included jBASE commands like SORT, LIST, COUNT, or whatever, can be run directly from the O/S Shell - that's true.  However, Pick people like the familiarity of TCL.  So, jBASE provides a 'TCL' program called jsh (jshell).  It gives the comfort of TCL if that's your preference.  And you can switch in and out of jsh to regular shell whenever you wish.  Most customers coming from Pick use jsh.  Users without Pick muscle memory run from the O/S shell.  jBASE doesn't care which way is used.

If you run at the O/S shell, you can do cool stuff like pipelining

 MY_BASIC_PROGAM | MY_UNIX_SCRIPT

or do things like:

$ SORT MYFILE BY THIS BY THAT | grep "containingString" to filter results.

or

 SORT /tmp EQ "[containingstring[" to filter the pick way against a non-pick file without having to set a pointer to that resource.

or be within a bash script and just call your program or jBASE command like it was any other UNIX command (or powershell).  However, jsh is useful when doing things like wanting to SELECT and hold the active select list for the next command... the more Pickie things.

jsh also has some really nice features like arrowing up and down through the stack (in addition to .L, .X, etc.) and you can left/right arrow, replace, etc.  It's a really nice TCL actually.

Bruce

Jim Idle

unread,
Oct 18, 2024, 3:29:18 PM10/18/24
to mvd...@googlegroups.com
No I mean the JQLXXXXXX functions in BASIC rather than EXECUTE.

I think what you are trying to port does not really fit with jBASE to be honest, though you can make it work with some effort, I am sure.

look at the SYSTEM(n) options
look at jstat

The bin directories for the install are all the commands available.

And use OBjEX as Bruce says earlier (hi Bruce)

Jim

Jim Idle

unread,
Oct 18, 2024, 3:31:06 PM10/18/24
to mvd...@googlegroups.com
Nah - these days you can make it look and feel exactly like D3 if you wish it to, but most people don't. Hence a tool like this will be less valuable unless it is adapted to what most jBASE users will be doing.

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mvdbms+un...@googlegroups.com.

Mike Yates

unread,
Oct 21, 2024, 6:49:09 AM10/21/24
to Pick and MultiValue Databases
So, do jBase users avoid TCL and Basic, as a whole?
My "Pick Explorer" is intended for admins rather than users, to take a quick look around an installation to see what exactly is there and how it is set up, without all that tedious typing. Have you tried it in SD64, Jim?
My Universe port is still held up by TERM malfunction (evaluation only) and jBase by KEYIN() malfunction.
Pity I lost my original Universe port source.

Wols Lists

unread,
Oct 21, 2024, 4:20:41 PM10/21/24
to mvd...@googlegroups.com
On 21/10/2024 11:49, Mike Yates wrote:
> So, do jBase users avoid TCL and Basic, as a whole?
> My "Pick Explorer" is intended for admins rather than users, to take a
> quick look around an installation to see what exactly is there and how
> it is set up, without all that tedious typing. Have you tried it in
> SD64, Jim?
> My Universe port is still held up by TERM malfunction (evaluation only)
> and jBase by KEYIN() malfunction.
> Pity I lost my original Universe port source.

Have you taken into account that INFORMATION-flavour installations don't
have q-pointers?

Have you taken into account that INFORMATION-flavour installations don't
have a master MD (or VOC) and ACCOUNTS file?

Okay, I know they have compatibility mode, but INFORMATION itself had no
central list of accounts, hence couldn't have q-pointers (because they
had no way of knowing where an account was located).

Those features are completely optional in INFORMATION-style systems, and
I've personally (being very much an INFORMATION and not Pick guy) almost
never seen them used.

Cheers,
Wol

Jim Idle

unread,
Oct 21, 2024, 6:16:49 PM10/21/24
to mvd...@googlegroups.com
For jBASE we provide a whole library for processing keyboard input. Way better than KEYIN. 


I don’t think jBASE users avoid TCL. We wrote jSH reform that, but once you learn zsh, you’ll not look back. 

Feel free to ask for any guidance. 

Jim


Mike Yates

unread,
Oct 22, 2024, 7:52:46 AM10/22/24
to mvd...@googlegroups.com
Fair enough, Wol, I'm only offering a 1991 tool I wrote in Universe Pick. I've used D3 and Universe as backend databases for web applications, too, and they still needed building and maintaining at TCL level. Nowadays that may be totally automatic (please point me to detailed info on that) but surely someone has to set it all up initially, so would be glad to reduce the tedium of that task?
I know nothing of what backend database Tesco use but, this year, I have seen (elderly) staff using a TCL based menu system within a store to "get the true stock picture" and  I glimpsed Pick query commands flash on the screen as it worked.

Mike Yates            Cowley, Middlesex, England

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms
---
You received this message because you are subscribed to a topic in the Google Groups "Pick and MultiValue Databases" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mvdbms/tGt6f2AnM5s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mvdbms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mvdbms/befba790-09fe-413f-af79-d7313c84310f%40youngman.org.uk.

Patrick Payne

unread,
Oct 22, 2024, 12:57:21 PM10/22/24
to Pick and MultiValue Databases
I thought I would chime in here.  Yes, most users use jsh.  Power users doing primarily development will start to lean towards shells.  MV systems have a unique shell concept and if you need those capabilities, you want jsh.   Here are some important points.

1. jBASE uses environment variables to setup the world.  Where to compile, where to find programs, emulation settings, etc.  These need to be setup before you run stuff.  jBASE has multiple techniques to do this for you.  
    a. There is a system file that emulates other systems (like d3).  You can setup this file and then use a classic logto or jb then account command to allow jBASE to do this for you.  Later jsh had a -a switch added that will do this setup for you if running from bash.  This is for consistency especially around compiler and emulation directives.  Power users do this themselves in some sh script they run but you have to be careful on production systems to maintain consistency.
    b. Shell Scripts as stated above and with the caveat mentions.
    c. jBASE 5.8 now has a master json config file that is always read and can setup normal system wide stuff.  It has options to always set value or only set if not already set.  This gives you the ability to enforce systemwide a setting or allow a power user to set it before running jBASE and it will not be overridden.  Keep in mind the Account features triggered by logto will override stuff.
2. Running jBASE outside jsh (which is itself a basic program) means you are starting a jbase session and then tearing it down with each command.  This is similar to other platforms (d3tcl for example).  This affects a bunch of stuff
      a. Port assignment - Each command is setting up jBASE and tearing it down, this means you may have different port assignments from command to command.
      b. License assignment - You are getting a license and releasing it between each command.
      c. Stacked commands!!!!!  Commands like GET-LIST/SAVE-LIST/COPY that stack stuff and then expect a second input are cleared between commands.  zsh/bash/etc do not have this concept.  This is why jsh exists to emulate this.  Be careful doing something with  GET-LIST and then a stacked command because based on emulation it may process the entire file. To be clear, doing a GET-LIST MYLIST will get the list and return out of jbase that will clear the list.  You are NOT DOING YOUR NEXT COMMAND AGAINST THE LIST!!!  There is NO GET-LIST active anymore!   There may be tricks somebody knows of to make this work but I personally find it dangerous.  As a actual DB user I use this all the time and need it.
      d. TCL stacks - This is a feature of jsh and it emulates tcl stacks for most platforms.  As a D3 user it is very close and even has the tclstack file (it is somehwere else but a Q pointer can be setup to emulate it).  But it does not do auto-completion which is something you get with the unix shells.
      e. Named Commons.  These are obviously reset after each command.  If you wish to persist one between programs, then you need jsh.
      f. Possible speed differences.  jBASE to gain speed and other features actually compiles all programs as a shared library also.  This allows jBASE once it is started to call these shared library versions of programs vs constantly starting a new pid and a new program.  Even if you start from zsh you will get this feature if you are executing stuff from within your program.  But if you are doing a bunch of work in a shell script you will be launching a new jBASE environment for each command.  Based on what you are doing it could affect performance.
      g. Escaping - If you are in a unix shell you get unix escaping first.  This means SELECT MYFILE WITH *A1 = "NAME\LAST" will not work the way you think.  The * and the \ are going to get unix escaping.  Keep in mind when in jsh there are options to change how it handles this stuff.  Look at the jsh documentation.

These reasons are why jBASE has jsh and the account stuff to give you a world that emulates what classic MV apps expect.  But it also allows you to get the full power of the native shell (powershell or Bash).  As a developer or DevOps person this is super powerful.  With Docker compose files for example you can just jBASE/MV commands directly with the carveouts mentioned above.  If you are doing new development, you can drop most of the MV environment stuff and use jBASE as you would use any other C++ tool.  If you are using MV environments you can pick and choose which O/S tools you like.   But it can also bite you if a consultant comes in and works directly from jsh with their own emulation settings and start recompiling stuff.  Emulations can affect stuff like Named commons, dims, how shared objects are created, etc.  jBASE is designed to emulate most MV platforms and these differences matter. 

Here is a very powerful example.

Let's say you wish to test some changes to a main program on a Production system (yes we are not supposed to do this but we know it is done).  On jBASE you can modify your environment to where it looks for programs and libraries.  These are typically PATH for programs and JBCOBJECTLIST for subroutines.  A production system may set this to

PATH=/myaccounts/myaccount/bin;**normal linux stuff**; * where to look for programs.
JBCOBJECTLIST=/myaccounts/myaccount/lib; * where to look for subroutines
JBCDEV_BIN=/myaccounts/myaccount/bin; where to compile programs
JBCDEV_LIB=/myaccounts/myaccount/lib; * where to compile subroutines

As a support person you can setup yours to be this

PATH=$HOME/testbin;/myaccounts/myaccount/bin;**normal linux stuff**; * where to look for programs.
JBCOBJECTLIST=$HOME/mylib;/myaccounts/myaccount/lib; * where to look for subroutines
JBCDEV_BIN=$HOME/bin; where to compile programs
JBCDEV_LI=$HOME/lib; * where to compile subroutines

You now have jBASE looking in your own private program/subroutine area first for code before looking in the main one.  We also instructed jBASE to compile to that private area.  You can now recompile anything and you are not affecting other users.  This feature can also be used to have different release levels of your software on the same machine.  Other platforms like d3 can do a little of this while others have a few assigned catalog spaces.  With jBASE you can use normal O/S pathing to have as many as you want.  Since everything is done via Environmental Variables this trick can be done for all sorts of stuff for different cases (let's say multi-tenancy).  This is why jBASE often has no items for programs and files in the Voc/MD.  jBASE will use the VOC/MD item first, it will then fall back on these environment variables.  The ability to adjust those on the fly give you incredible power.

Here are other powerful items that you can use for all sorts of items (such as multi-tenancy) or special security situations (custom MD/VOC for different users)

SPOOLER LOCATION
LIST FILE LOCATION
SYSTEM FILE TO USE
MD/VOC TO USE
PATH (file locations, allows multiple locations that are searched in order)  

Ok, this was long winded but hopefully it shows the overall flexibility and explains that with great power comes great responsibility.  If you wish to work from only zsh then fully understand the differences.  Also if you are publishing to a production system not doing this then please make sure you test your code in the classic mode =)


Wols Lists

unread,
Oct 22, 2024, 2:45:36 PM10/22/24
to mvd...@googlegroups.com
On 22/10/2024 17:57, Patrick Payne wrote:
> To be clear, doing a GET-LIST MYLIST will get the list and return out of
> jbase that will clear the list.  You are NOT DOING YOUR NEXT COMMAND
> AGAINST THE LIST!!!  There is NO GET-LIST active anymore!   There may be
> tricks somebody knows of to make this work but I personally find it
> dangerous.  As a actual DB user I use this all the time and need it.

Dunno whether jBase has it, but INFORMATION (and presumably UV et al)
have the REQUIRE.SELECT OPTION. If there's no active select list, the
command will abort.

This protects against the select command unexpectedly returning an empty
list.

Cheers,
Wol
Reply all
Reply to author
Forward
0 new messages