AnsweredAssumed Answered

Using Variables to Search for Records

Question asked by kayakjunkie on May 15, 2012
Latest reply on May 16, 2012 by Jason Wood


Using Variables to Search for Records & Select Layout


Related -

I'm trying to perform a search based on a the contents of a variable.  I'm looking for the correct syntax so that a variable (i.e. $type = "pos" ) can end up in the criteria field as *"pos"*

I've tried defining the variable in different ways including "*"pos"*" or "*" & ""pos"" & "*" only to be told that the table pos cannot be found.

1)  How do I write the variable definition so that I can end up with *"pos"* ?

2)  What is the correct syntax so that the variable is placed in the criteria field correctly ( Set Field [Table::Field ; $type] )?


The table has two fields, 1) importDate and 2) importPath

importPath has the path to various files that will be imported.

Example:  /Users/Jesse/Dropbox/Databases/Tests/Temp/pos120501.CSV

Each File Name has a prefix ( in this case "pos" ) that indicates the contents of the file and to which table the contents will be imported.

Here is an abbreviated version of the script.  I've highlighted the section where I'm having trouble:


Go to Layout ["Import" (Import)]


Set Variable ($f; Value:$f + 1)

If[$f = 1]

Set Variable ($type; Value:"pos")

Else If[$f = 2; Value:"pri"]

Set Variable ($type; Value:"pri")

Exit Loop If[$f = 2]

End If

Enter Find Mode []

Set Field [Import::importPath[$type]]  // I've also tried preceding this with Go to Field [Import::importPath]

Set Error Capture [On]

Perform Find []

Set Variable [$k; Value:0]


Set Variable [$k; Value:$k + 1]

Set Variable [$records; Value:Get (FoundCount)]

If [$k = 1]

Go to Record [First]


Go to Record [Next]

End If

Set Variable [$Import; Value:"file:Temp/"&Right (Import::importPath ; 13 )]

If [$f = 1]

Go to Layout ["Positions" (Positions)]

Else If [$f = 2]

Go to Layout ["Prices" (Prices)]

End If

Import Records [No dialog; "$Import"]

Exit Loop If ($k > $records)

End Loop

End Loop