Skip to main content

Automatically run the same script multiple times

 
I have a table where all records have a unique id number. Very simply put I have a script that stores the data from a specific record in a new table. The problem is that i have a list of hundreds of ID’s that need to get stored in an individual table. Instead of running the script manually a couple of hundred times, each time with a different ID number, i would like to automate this. It should go through the list running the script for each ID number. I have searched the forum but i couldn’t find a matching topic. I was thinking about a loop function but my knowledge of idea script is to limited at this time. Can you help me please?
  
See the attached excel file for a simple example:
  
Thank you!Best regards, Mike

Brian Element Mon, 05/20/2019 - 14:23

Hi Mike,

Are you looking for an a python or IDEAScript answer to this?  Klmi supplied the python and in IDEAScript you would need a for loop such as:

for i = 1 to count

    do something

next i

 

Mike72 Mon, 05/20/2019 - 16:04

In reply to by Brian Element

Hi Brian, i was just trying some things and to be honest i did not understand much of Klmi his or her's solution. I am looking for an ideascript. I allready got it working with the for i next i script, but now i run into another problem. In the extractian part i use an @isini function (see script: eqn = "@Isini(""" & keyword & """;VELD1)") . The problem with this is that i need an exact match with the keyword. For example when i search for records in table A with the keyword 1 from Table B, it will show not only 1 as a result, but also 10. There should be only the record with 1 as a result from the @isini function. Is there a way to add script to the @isini function so that the result is only an exact match. I hope you still follow me.
 
I added a txt with my script.
 

Mike72 Tue, 05/21/2019 - 05:40

In reply to by Brian Element

Hi Brian, the script (see attached file) works fine, however this script only works when the keyword field and field to match are character fields. What if those fields are numeric fields. What can i change in my script to use it with numeric fields. I've tried some different things but none of them worked.
 
Thanks!
 
 

Brian Element Tue, 05/21/2019 - 07:52

In reply to by Mike72

Hi Mike,

What you need to do is first test to see if the field is numeric or character.  You can use the field.IsNumeric - field.IsCharacter for this test.  Create a variable to hold the results.

Next when you are extracting the value of the field your code would be:

if sFieldType = "Char" then 'assumes that your variable to hold the type has Char for a characteter field

     keyword = rec.GetCharValueAt(1)

else 'if not character then numeric

     keyword = rec.GetNumValueAt(1)

end if

Call Step_02(keyword, sFieldType )

Also you will have to redefine your keyword as variant so it can hold either string or numeric items.

For Step_02 change the (ByVal keyword As String) to (ByVal keyword As Variant, ByValy sFieldType as string) if you don't do this IDEA will give an error as the item being received has to be of the same type as the item being sent.  You also have to send over the field type.

If the step 2 function you will need to change the equation depending on the field type

if sFieldType = "Char" then

     eqn = "@match(DATAFIELD_1;""" & keyword & """)"

else

     eqn = "DATAFIELD_1= " & keyword & ")"

end if

Hopefully this makes sense.  I haven't actually tested the code so I might have a typo in the above code.

Good luck in your project.

Brian

Mike72 Mon, 05/27/2019 - 08:10

Hi Brian i took only the numeric part of your solution because the relevant fields in my tables where numeric so i didn't have to check whether they where char or num. And it worked great so my problem is solved!
Thanks for your help.
Mike