Forum Post: Code Highlighter available within our Community

Status
Not open for further replies.
J

Jean Richert

Guest
Just a short post to let all of you know that we just improved the code highlighter within the Community and added ABL. Wondering how to use it? Follow this link for explanations and you'll be able to have ABL nicely displayed within our Community and the example bellow DEFINE VARIABLE myObj AS JsonObject NO-UNDO. DEFINE VARIABLE myElem AS JsonObject NO-UNDO. DEFINE VARIABLE myArray AS JsonArray NO-UNDO. DEFINE VARIABLE myLongchar AS LONGCHAR NO-UNDO. DEFINE VARIABLE lv_Property AS CHARACTER EXTENT no-undo. DEFINE VARIABLE lv_Property1 AS CHARACTER EXTENT no-undo. DEFINE VARIABLE lv_i AS INTEGER NO-UNDO. DEFINE VARIABLE lv_i2 AS INTEGER NO-UNDO. DEFINE TEMP-TABLE ttCust FIELD CustNum AS INTEGER FIELD Name AS CHARACTER FIELD CreditLimit AS DECIMAL FIELD someLogic AS LOGICAL . /* . . Load temp-table . */ FOR EACH Customer WHERE CustNum < 5 NO-LOCK: CREATE ttCust. BUFFER-COPY Customer to ttCust. END. /* Let's create json object.. */ myObj = NEW JsonObject(). /* ..and load it with ttCust data */ myObj:Read(TEMP-TABLE ttCust:HANDLE). /* we can get names of all properties within json object */ lv_Property = myObj:GetNames(). /* Here you get message "ttCust" as this json object contains one element */ /* and that is JsonArray with its elements being ttCust records */ MESSAGE "Number of elements in root json object is " EXTENT(lv_Property) VIEW-AS ALERT-BOX INFO BUTTONS OK. /* Let's write our json to a file so that we can examine it's structure */ myObj:WRITEfile("ttCust.txt") . /* so let's fetch our array from myObj's array property) */ myArray = myObj:GetJsonArray("ttCust") . /* and let's report on it's length */ MESSAGE "Array's length is " myArray:Length VIEW-AS ALERT-BOX INFO BUTTONS OK. /* Let's go through the json array elements */ DO lv_i = 1 TO myArray:Length : myElem = myArray:GetJsonObject(lv_i) . lv_Property1 = myElem:GetNames(). DO lv_i2 = 1 TO EXTENT(lv_Property1) : MESSAGE "Property " lv_Property1[lv_i2] " has type : " myElem:GetType(lv_Property1[lv_i2]) VIEW-AS ALERT-BOX INFO BUTTONS OK. END. END. /* For other data types please check */ /* Progress.Json.ObjectModel.JsonDataType class */ /* Array property */ /* String property */ /* Number property */ /* Boolean property */ /* Object property */ /* Null property */

Continue reading...
 
Status
Not open for further replies.
Top