Key Value Extraction Array
Forums
Well I just learned something tonight. The IDEAScript for a key value extraction uses an array to hold all the values to extract. When I was creating the script I assumed that the array was one of string since it was holding text but when I did that the script kept giving me an error when I got to that line. Turns out that when you define the array you either don't tell IDEA what it is or define it as a Variant so it needs to be one of these:
Dim myArray(0,0) or Dim myArray(0,0) as Varient - if you define it as string it will give you an error. The code per the language browser is correct, they just don't give any explanation for what type the array is.
Sub Main
' Open the database
Set db = Client.OpenDatabase("Sample-Customers.IMD")
' Create the task.
Set task = db.KeyValueExtraction
' Define an array to specify the country names.
Dim myArray(1,0)
myArray(0,0) = "ARGENTINA"
myArray(1,0) = "SOUTH AFRICA"
' Configure the task.
task.IncludeAllFields
task.AddKey "COUNTRY", "A"
task.DBPrefix = "KeyVal"
task.CreateMultipleDatabases = True
task.ValuesToExtract myArray
' Perform the task and output the resulting database name.
task.PerformTask
dbName = task.DBName
' Clear the memory.
Set task = Nothing
Set db = Nothing
' Open the result.
Client.OpenDatabase(dbName)
End Sub
The main problem is that
dim summFieldArray(499,0) as variant
You would populate it with your array values so
summFieldArray(0,0) = "First Key"
summFieldArray(1,0) = "Second Key"
summFieldArray(2,0) = "Third Key"
and so on. Don't worry about the blanks, IDEA seems to ignore those.
Try this out and let me know how it goes.
Also- thanks so much for this
Also- thanks so much for this tip on the array type! I was driving myself to madness getting the "Invalid procedure call or argument" error repeatedly when I KNEW I was passing a string array...