Using iLogic to check if a parameter already exists

Using iLogic to check if a parameter already exists

EScales
Advocate Advocate
1,333 Views
1 Reply
Message 1 of 2

Using iLogic to check if a parameter already exists

EScales
Advocate
Advocate

I could use some help creating a statement in an external rule.  I have an .xml file which contains a list of custom parameters with default settings. 

When I open an existing part file, I want to check to see if these parameters already exist.  If they do not exist, I want to use iLogicVb.Automation.ParametersXmlLoad(ThisDoc.Document, “path\filename.xml") to import the parameters.  If they already exist, I want to skip this step and move on with the rest of my rule.

What type of statement can I add to check if a parameter already exists, regardless of what value that parameter may be set to?  It's basically a true/false question.  Does it exist? Yes or No.  That's what I want to know.  If yes, then do one thing.  If no, then do something else.

Any suggestions?

 

0 Likes
1,334 Views
1 Reply
Reply (1)
Message 2 of 2

Owner2229
Advisor
Advisor

I don't know how XML parameters imporing work, but wouldn't it be easier with excel table?

GoExcel.Open("...path...\Parameters.xlsx", "List1")
If String.IsNullOrEmpty(GoExcel.CellValue("A1")) Then ...

Anyway you could probably convert these parameters to string and use:

 

If String.IsNullOrEmpty(...Parameter...) Then
...

This is what I'm currently using to search Excel table for existing Part Numer:

 

 

GoExcel.Open("...path...\Parameters.xlsx", "List1")
RowEnd = 200
For countA = 1 To 10 'Will count up to row 1200
If Not String.IsNullOrEmpty(GoExcel.CellValue("A" & countA & 90)) Then
RowEnd = RowEnd + 100
Else
Exit For
End If
Next
RowStart = 2
skip = 0
For countB = RowStart To RowEnd
If GoExcel.CellValue("A" & countB) = iProperties.Value("Project", "Part Number") Then
skip = countB
Exit For
Else If String.IsNullOrEmpty(GoExcel.CellValue("A" & countB))
i = i + 1
End If
Next
If skip = 0 Then
'Next empty row is max rows minus blank rows plus one
row = RowEnd - i + 1
MsgBox("Part was written on row nr. " & row)
Else
row = skip
MsgBox("Part was actualized on row nr. " & row)
End If
GoExcel.CellValue("A" & row) = iProperties.Value("Project", "Part Number")

^^ It looks for row with same Part Number as the part have and actualizes it's data or writes new data on next free row.

 

I hope something of it would help you.

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes