Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?



Add $merge() and $locate() as internal methods to dynamic objects

Previous Release Behavior

Methods did not exist. You had to do an iterator in your code to support the equivalent of $merge() and $locate()

Current Release Behavior

You can use $merge() to merge one object into another. The objects types must match, either both must be object or both must be arrays -- you can't merge an array into an object.

You can use $locate() to find a string in a dynamic array (not in an object). The result is -1 for the string not found, or a positive value showing the relative index value in the array if the string was found.

This is an example of merging object 'source' into 'destination'

debian-~/tmp1: cat test4.jabba
    source = new object
    destination = new object
    source->name = "greg"
    source->weight = 112
    source->shame = @true
    destination->postcode = "AL1 4JU"
    destination->town = "Hucknall"
* Merge 'source' into 'destination'
* Display the results. 'destination' will now have all the combined properties.
    print destination->$tojson(1)
debian-~/tmp1: jcompile test4.jabba -o test4
debian-~/tmp1: ./test4
        "postcode":"AL1 4JU",

This is an example of using $locate() with and without case sensitivity.

debian-~/src/International/development/jbase: cat test7.jabba
    arr = new array
* Look for Ian
    rc = arr->$locate("Ian")
    if rc lt 0 then print "Ian is not in array" ; stop
    print arr[rc]:" is in array at element ":rc
* Do a case insensitive test
    rc = arr->$locate("IAN",1)
    if rc lt 0 then print "Ian is not in array" ; stop
    print arr[rc]:" is in array at element ":rc
debian-~/src/International/development/jbase: jcompile test7.jabba -o test7
debian-~/src/International/development/jbase: test7
Ian is in array at element 1
Ian is in array at element 1

Was this article helpful?