2 scripting problems, droplistbox, merging records

11 posts / 0 new
Last post
freetgy
Offline
Joined: 07/11/2014 - 11:24
2 scripting problems, droplistbox, merging records

Hi everyone,
i have 2 problems which i could not manage to get solved yet and i hope you can help me finally solving the puzzle.
1. Droplistbox
I am using (multiple) droplistbox to select different IDEA-DB files, to execute some special scripts i have developed. The droplistbox is filled with an array of IDEA-DB files in the working directory.
What i would like is preselect one element of the array that fills the droplistbox, currently it seems IDEA sorts the array by alphabet and just shows the first entry and there is no documented way to change that behaviour (e. g. like setting a different Index)
How can i achieve this?
2. Merging values of a field for multiple line items
I have some fields in a IDEA database that are strucured like this:

  • Column1, Column2
  • 1, A
  • 1, B
  • 1, C
  • 2, A
  • 2, B
  • 2, D

What i am looking for is a way to merge the info of Column2 into one linen so the result looks like this:

  • 1, A+B+C
  • 2, A+B+D

Alternatively, the single values of A+B+C could also be writen in seperate columns, e. g.

  • 1, A, B, C
  • 2, A, B, D

However the number of data lines to be merged can vary based on the data.
Thank you very much for your support
Freetgy

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Droplistbox

Hi freetgy, the order that the items appears in a drop box in the dialog is based on the order they are entered in an array.  The following is an example of having a dialog with two drop boxes with four items in each.  As you can see from the code the order is reserved in the example 2 drop box and that shows as the first item is always the items that is first in the array.  So in your example you would have to create some code to order the items to show-up correctly in your dialog.

 

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Merging values of a field for multiple line items

Off the top of my head I can't think of a way to do that in IDEA, it would have to be scripted.  Basically you would need to create a new database that would hold the information.  You would then loop through all the transactions in the old database and place them in the new lines in the new database. I could put together an example code for you to try out.

Brian

freetgy
Offline
Joined: 07/11/2014 - 11:24

re 1.
If it is the order entered in the array i can work with that.thank you very much for the information, might require little bit of reworking the scripts, but that's fine :)
re 2.
It is not doable in IDEA, that much i realized as well. I had an alternate IDEA using an actionfield on Column1 with an ideascript and the relevant parameters to output me the relevant lines in the database. But your IDEA sounds good as well.Any help to solution is appreciated very much.
Thanks alot :)!!!!
Freetgy

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

re 1. if you look in the snippets section there is some code on how to order an array that might give you some help.

re 2. I will try and give you some code this evening on how to do it.   Any idea what the field length would need to be or do I just assume the maximum in IDEA?

freetgy
Offline
Joined: 07/11/2014 - 11:24

re1:
already have my solution works for me, see attached for others if needed (reorder array elements based on content)
Dim a As Integer a = 0
b = 0 For Each Entry In Array
If(iIsini("Whatilookfor",Entry)) Then
Array(a) = Entry
a = a+1
Else
Array(UBound(Array)-b) = Eintrag
b = b+1
End If
Next
re2:
thank you looking forward to it.
PS:
on a sidenote i need help on a very basic problem how do i declare an array in ideascript based on a variable that is determined on runtime? I always seem to get a compilation error

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Glad you found your solution. 

re 2 - I will try and post something for you tonight.

For the declations you can do something like this.

Dim aArray() as string 'defines the string but does not allocate the number of elements

ReDim aArray(6) 'allocates 7 elements to the array, if the array already exists it would destroy the previous array and recreate it.  To add elements you can use the Perserve command.

 

freetgy
Offline
Joined: 07/11/2014 - 11:24

re Array question:
ok it seems my problem lies not with declaring a normal array but an array with multiple dimensions
e. g.
Dim aArray()
Redim aArray(5,2)
throws out an syntax error. for me

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

In my view IDEA doesn't do multiple dimension arrays properly.  Unfortunately you can't ReDim a multi array.  What you have to do is figure out the largest it will need to be and dimension when you create it.  If there is a way to ReDim a multi array I haven't figured it out yet, the ReDim only seems to work on normal arrays.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

re 2 - ok, here is one solution. 

This is the database that I used:

and this is what it looks like after:

I have attached the script and the source file.  I didn't do much in the way of error checking or anything like that which I would usually do for my scripts.  It is really there to give you an idea of one way to do this.  I didn't document the script much so if you have problems let me know and I can document it for you or let me know if you have any questions on the code and I will help you out.

freetgy
Offline
Joined: 07/11/2014 - 11:24

re 2. Questions:
Thank you very much,
didn't have a chance yet, i'll have a look today