null

Making Old New

jBASE Dynamic Objects (jDO) enhances your ability to hire developers. Instead of spending time teaching people procedural code, let them work as they normally would in an Object-Oriented mindset and start delivering new innovations.

Object Oriented Programming for PICK

Discover jBASE Dynamic Objects (jDO), an enhancement to the BASIC programming language. Dynamic Objects adds familiar mechanisms of Object-Oriented programming such as objects, methods, and classes expanding the functionality of any jBASE program. jDO is also not an ‘all-or-nothing’ approach to extending new or existing business logic as you can seamlessly inject as much or as little Object-Oriented code right alongside traditional BASIC. This allows a great amount of flexibility without being concerned with forklift-refactoring efforts. New Object-Oriented additions to the business logic become highly reusable and over-time your application will see faster implementation time with increased durability.

With jDO, there are built-in static methods available right out of the box like serializing/deserializing JSON strings to data objects. This brings an entirely new speed to application development while interfacing with the REST APIs out in the world. Here are some examples of working with jDO

$options jabba

RESULT.OBJ = NEW OBJECT; * build new object

OPEN "NW.ORDERS" TO FI.NW.ORDERS ELSE STOP "No orders file"

RESULT.OBJ->records = NEW ARRAY; * add an array called results inside result object

EXECUTE "SSELECT NW.ORDERS BY-DSND ORDERDATE"

CNTR=0
LOOP
    READNEXT ID ELSE EXIT
    CNTR+=1

    READ ORDER FROM FI.NW.ORDERS, ID ELSE CONTINUE
    ORDER.OBJ = NEW OBJECT; * build temporary object for this order

    ORDER.OBJ->orderid          = ID
    ORDER.OBJ->customerid       = ORDER<1>
    ORDER.OBJ->employeeid       = ORDER<2>
    ORDER.OBJ->orderdate        = OCONV(ORDER<3>,"D4-")
  
    NUMBER.ITEMS=DCOUNT(ORDER<10>,@VM); * count how many order lines we have

    ORDER.OBJ->items = NEW ARRAY; * add an array inside our order boject called items

    FOR V=1 TO NUMBER.ITEMS
        ITEMS.OBJ = NEW OBJECT; * temporary object for a single line item
        ITEMS.OBJ->productid   = ORDER<10,V>
        ITEMS.OBJ->unitprice   = OCONV(ORDER<11,V>,"MD2")
        ITEMS.OBJ->quantity    = ORDER<12,V>
  
        ORDER.OBJ->items->$append(ITEMS.OBJ); * append our item detal into our order items array
    NEXT V
    RESULT.OBJ->records->$append(ORDER.OBJ); * append our order into our records array
REPEAT

PRINT RESULT.OBJ->$tojson(1); * print our output to json

We can read it into a jBASE Dynamic Object, print the name, update the name and display the resultant JSON simply as follows. It is to manipulate a Dynamic Object created from a JSON string with constructs such as ‘print myobj->name’ – –

jsh Z2018 ~ -->BASIC BP NWORDERS.EXAMPLE
NWORDERS.EXAMPLE
BASIC_1.c
Source file NWORDERS.EXAMPLE compiled successfully
jsh Z2018 ~ -->CATALOG BP NWORDERS.EXAMPLE
NWORDERS.EXAMPLE
Object NWORDERS.EXAMPLE ( changed to nworders.example ) cataloged successfully
jsh Z2018 ~ -->GET-LIST EXAMPLE.LIST

 2 Records selected

>NWORDERS.EXAMPLE

 2 Records selected

{
   "records":[
      {
         "orderid": "10301",
         "customerid": "WANDK",
         "employeeid": "8",
         "orderdate": "09-09-1996",
         "items":[
            {
               "productid": "40",
               "unitprice": "14.70",
               "quantity": "10"
            },
            {
               "productid": "56",
               "unitprice": "30.40",
               "quantity": "20"
            }
         ]
      },
      {
         "orderid": "10258",
         "customerid": "ERNSH",
         "employeeid": "1",
         "orderdate": "07-17-1996",
         "items": [
            {
               "productid": "2",
               "unitprice": "15.20",
               "quantity": "50"
            },
            {
               "productid":"5",
               "unitprice":"17.00",
               "quantity":"65"
            },
            {
                "productid":"32",
                "unitprice":"25.60",
                "quantity":"6"
            }
         ]
      }
   ]
}
jsh Z2018 ~ -->

Create your own classes and convert output to JSON.

jDO enhances your ability to hire developers that don’t necessarily need to learn PICK BASIC to be successful and productive. Instead of spending time teaching people procedural code, let them work as they normally would in an Object-Oriented mindset and start delivering new innovations.

Want to learn more?