Quantcast
Channel: Baanboard.com
Viewing all articles
Browse latest Browse all 4216

Dynamic arrays

$
0
0
Putting together a report and would appreciate some guidance. I'm working entirely within Report Script. I need to have a dynamic array to store some string values that I can check against as I'm processing each line of the report. From what I've read up on I have to allocate and deallocate memory for this, which gets me a bit nervous so I want to make sure I'm doing it properly. The pseudocode for what I want to do would go something like this:

Code:

CREATE EMPTY ARRAY to store string values that are 9 characters long

DEFINE FUNCTION addToArray(newElement)
    ALLOCATE/RESIZE the current array
    ADD newElement to array
END FUNCTION

DEFINE FUNCTION existsInArray(stringValue)
    FOR all indexes of array
        IF stringValue = current index's value THEN
            RETURN true
        END IF
    END FOR
    RETURN false
END FUNCTION

DEFINE FUNCTION destroyArray
    FREE all memory allocated to the array
END FUNCTION

Within my before.layout of my detail section I could call the functions to decide what to do with the currently processing record. Then in an after.field section I'd essentially want to zero out the array values to start fresh. End of report, totally deallocate the array (if it's necessary).

Is this even possible? Or better yet, advisable? Any code examples of doing this properly would be greatly appreciated.

Kind regards,
Rich

Viewing all articles
Browse latest Browse all 4216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>