Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 7th April 2017, 18:39
lotius81 lotius81 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 25
lotius81 is on a distinguished road
Baan: Infor LN 10.4 - DB: SQL Server - OS: Windows Server 2008
Dynamic arrays
Baan: ERP LN 6.1 FP10 (Infor ERP 10.4)
C/S: None/Unknown

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
Reply With Quote
  #2  
Old 8th April 2017, 14:22
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 444
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
Yes, it is very much possible. What exactly is stopping you?

One thing i have in my mind is that, if you want to compare an existing detail section with some condition, why cant you compare it directly? I have a feeling you can do it directly instead of storing it in a dynamic array.
Reply With Quote
Sponsored Links
  #3  
Old 10th April 2017, 10:02
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,287
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Advise -

Once you are done with creating and filling the array, you can use qss.* functions for manipulation.

Here's a sample for qss.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #4  
Old 11th April 2017, 15:19
lotius81 lotius81 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 25
lotius81 is on a distinguished road
Baan: Infor LN 10.4 - DB: SQL Server - OS: Windows Server 2008
Quote:
Originally Posted by Ajesh View Post
Yes, it is very much possible. What exactly is stopping you?
I guess just a little unclear about the documentation and examples I've seen for allocating/deallocating arrays.

I'm guessing it'd go something like this

Code:
domain int currentArraySize = 0
domain string array(1) BASED

functions:
function addToArray(string newElement(9)) {
    currentArraySize = currentArraySize + 1
    alloc.mem(array, 9, currentArraySize)
    array(currentArraySize) = newElement
}

function existsInArray(stringValue) {
    for i = 1 to currentArraySize 
        if stringValue = array(i) then
            return true
        endif
    endfor
    return false
}

function destroyArray {
    free.mem(array)
}
Am I on the right track here?

Quote:
Originally Posted by Ajesh View Post
One thing i have in my mind is that, if you want to compare an existing detail section with some condition, why cant you compare it directly? I have a feeling you can do it directly instead of storing it in a dynamic array.
The way this particular report is running I need to be able to check if I've already encountered a particular field's value in a prior record. Otherwise, yes, I would just compare it directly. Unless there is a way to check for a previously encountered value, in which case I wouldn't need the array stuff at all.

Thanks much for any input!
Reply With Quote
  #5  
Old 12th April 2017, 03:30
Ajesh's Avatar
Ajesh Ajesh is offline
Guru
 
Join Date: Feb 2009
Posts: 444
Ajesh is on a distinguished road
Baan: LN 10.4 - DB: Oracle - OS: HP-Unix
That looks pretty much right..
Reply With Quote
  #6  
Old 12th April 2017, 21:56
lotius81 lotius81 is offline
Junior Member
 
Join Date: Nov 2016
Posts: 25
lotius81 is on a distinguished road
Baan: Infor LN 10.4 - DB: SQL Server - OS: Windows Server 2008
Okay! After testing and fighting with it this afternoon I've got it working. I'll post it here so if anyone does a search they can maybe use it as a reference for their own solutions.

This basically stores strings that are 9 characters long into an array, increases the size of the array as needed, checks against the array for an existing value, and wipes the array out when done.

First, created a string array and a current array size variable in the declarations section:

Code:
       domain  tcmcs.int            currentArraySize
       extern  string               orderArray(1,1) based
Create the functions in the functions section:

Code:
     function addToArray(domain tcmcs.str9 newElement) {
         currentArraySize = currentArraySize + 1
         alloc.mem(orderArray, 9, currentArraySize)
         orderArray(1,currentArraySize) = newElement
     }

     function boolean existsInArray(domain tcmcs.str9 stringValue) {
          domain tcmcs.int i
          for i = 1 to currentArraySize 
               if stringValue = orderArray(1,i) then
                    return(true)
               endif
          endfor
          return(false)
     }

     function destroyArray() {
          free.mem(orderArray)
          currentArraySize = 0
     }
I call them in my detail section as needed, works like a champ!

Code:
       if existsInArray(orno) then
            |* do some work
       else
            addToArray(orno)
       endif
After I'm done...

Code:
      destroyArray()
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic form 'Run-time error 13' Type Mismatch baan_afbs Tools Development 8 21st November 2013 23:28
dynamic arrays ??? learner Tools Development 12 25th March 2008 16:48
dynamic bind for dynamic sql problem Andre.A Tools Development 8 8th January 2007 15:19
Arrays in OLE Ruskin AFS/DDC/OLE: Function servers 9 20th March 2003 22:21
Using stpapi.insert with Dynamic Forms dbclark79 AFS/DDC/OLE: Function servers 3 24th October 2002 22:51


All times are GMT +2. The time now is 06:24.


©2001-2017 - Baanboard.com - Baanforums.com