3 Replies Latest reply on Dec 13, 2013 2:16 PM by philmodjunk

    Script Parameter using Text



      Script Parameter using Text


           I am trying to set a script parameter using two text objects:

           a= "Insurance";b= "T24a_Insurance_Patients||Id_Patient|"

           Running the script:

           $$Filetype = Evaluate("Let([" & Get(ScriptParameter) & "];a)")

           $$Path = Evaluate("Let([" & Get(ScriptParameter) & "];b)")

           $$Filename = Let([PatientID = $$Path & "::ID_Patient"; FamilyID=$$Path &"::ID_Family"];

           Evaluate("PatientID") & "|" & Evaluate("FamilyID") & "|" & $$Filetype &  "|"  & 

           Year(Get(CurrentDate)) & "|" & 
           Left(MonthName(Get(CurrentDate));3) & "|" & 
           Day(Get(CurrentDate)) & ".PDF"
           This is to create a PDF from a database where different tables have the data needed.  The problem is that the script parameters require quotes.  I tried using single quotes embedded, but that doesn't seem to work.  I know there may be problems with the $$Filename portion of the script, but I can't even get values for the $$Path or $$FileType portions of the script.

        • 1. Re: Script Parameter using Text

               Option 1:

               "a= "& Quote ( "Insurance") & ";b= " & Quote ( "T24a_Insurance_Patients||Id_Patient|")

               Option 2:

               "a= \"Insurance\";b= \"T24a_Insurance_Patients||Id_Patient|\""

               but the literal text: T24a_Insurance_Patients||Id_Patient doesn't look like a valid file path, so maybe that shouldn't be quoted.

               You might also consider this let expression:

               Set Variable [ $Dummy ; Value: "Let ( [ $$Filetype = \"Insurance\" ; $$Path = \"T24a_Insurance_Patients||Id_Patient|\"]; 1 )" ]

               As a way to set values to these two variables in one step. Of course it would actually look like:

               Set Variable [ $Dummy ; Value: Evaluate ( Get ( ScriptParameter ) ) ]

               And if your list of values to pass as a parameter are never null (or only one can ever be null), you can use this simpler method:

               Script Parameter: List ( "Insurance" ;  "T24a_Insurance_Patients||Id_Patient|")

               Set Variable [ $$Filetype ; value: GetValue ( Get(ScriptParameter)  ; 1 ))

               Set Variable [ $$Path ; value: GetValue ( Get(ScriptParameter)  ; 2 ))

          • 2. Re: Script Parameter using Text

                 Option 1 worked.  The path is valid - it's how I know how tables are linked.  Thanks

            • 3. Re: Script Parameter using Text

                   Ok, it's matter of terminology. That is NOT a file path, it's a reference to a table occurrence in your database and thus is a valid reference. wink

                   I will note one bit of caution here with your indirect data references: When you put file names, Layout names, table occurrence names or field names into an expression as quoted text like this, your solution becomes a bit "brittle" (easily broken). If you later rename the object so referenced--which is easy to do and will not throw up any error or warning messages, your expression now fails to evaluate correctly and thus "breaks".

                   I thus try to avoid a literal string for such objects if there is any alternative.

                   I can, for example, pass a field reference as a script parameter with this expression: GetFieldName ( TableOccurrence::FieldName ) and then renaming the table, table occurrence or field will not cause the wrong text to be used to refer to that field.

                   Get ( LayoutTableName ) can also be a useful way to get to a table occurrence name without needing quoted text to do it.