Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnCOBOL

GitHub Actions Workflow Status GitHub Release IBM Cobol

Experimenting with JSON-like storage on places it should not exist.

Cobol standards and versions

Most of the codebase is compatible with cobol85, the oldest cobol standard in GnuCOBOL which is forward compatible.

However, some specific programs need more advanced features (mainly recursive) so they are compiled with ibm (which can also compile everything). This may change in the future, as an older cobol version with recursive support may be chosen or the dependency on recursive may be dropped altogether.

Documentation (barebones)

Importing the library

While some compilers have easier routes, this is the standard way to include the library (in gnucobol for example):

cobc -x yourprogram.cob uncobol/*.cob

You can also type out each file (utils_removeLastDot, uncobol_edit, obj_set...), but you will probably have to change that every time you want to update the library (which can be done by just cloning a newer version) as the library's structure may change in the future.

Simple example

From tests/test_all.cob

*   DATA DIVISION.
*   local-storage section, working-storage section or linkage section
    01  storage.
        02 stored-item OCCURS 20 TIMES.
            03 item-name            PIC X(10).
            03 item-value           PIC X(20).
            03 parent               PIC 9(2).
            03 children             OCCURS 5 TIMES.
                04 child-name       PIC X(10).
                04 child-num        PIC 9(2).

    01  target_object           PIC X(255).
    01  object_value            PIC X(20).
    01  got-value               PIC X(20).



*   PROCEDURE DIVISION.
*   Initialize
    CALL "obj_init" USING BY REFERENCE storage.

*   Create a simple structure:
*   main: {
*       a: {
*           c: "hello" 
*       }
*   }
    MOVE "main.a.c" TO target_object.
    MOVE "hello" TO object_value.
    CALL "obj_set" USING BY REFERENCE storage target_object
        object_value.
    
*   Get value of `main.a.c`
    CALL "obj_get" USING by reference storage target_object
        got-value.
    DISPLAY got-value.
* Expected: hello

*   Delete only main.a.c (not main.a as a whole)
    CALL "obj_del" USING BY REFERENCE storage target_object.
*   Check if main.a.c exists
    MOVE low-value TO got-value.
    CALL "obj_get" USING BY REFERENCE storage target_object
        got-value.
    DISPLAY got-value.
*   ^ Expected: null

    STOP RUN.

Export as JSON

*   DATA DIVISION.
*   local-storage section, working-storage section or linkage section
    01  storage.
        02 stored-item OCCURS 20 TIMES.
            03 item-name            PIC X(10).
            03 item-value           PIC X(20).
            03 parent               PIC 9(2).
            03 children             OCCURS 5 TIMES.
                04 child-name       PIC X(10).
                04 child-num        PIC 9(2).
    
    01  start_at                    PIC 9(2).
    01  start_level                 PIC 9(2).
    01  edit_string                 PIC X(255) value spaces.

*   PROCEDURE DIVISION.
*   ...initialize and edit the storage...
    CALL "obj_toJSON" USING BY REFERENCE storage start_at
        start_level edit_string.
    DISPLAY edit_string.
*   ^ Expected: {...}

About

Experimenting with JSON-like storage on places it should not exist

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages