0

Script: Test for 'if this is true and that is true, then..."

I have a working script which does what I wanted, some reference numbers need to be in the format AB-C-D and others ABCD. With and without hyphens depending on two tests.

if 'Year Code'.Year < 1996 then
'Year Code'.'Year Code' + "-" + Folder.Book + "-" + Page
else
'Year Code'.'Year Code' + 'Month Code'.'Month Code' + Day + 'Day Sequence'
end

I want to add a second test after the year test saying AND 'This Field' contains exactly "These Words"

 

I tried 

 

if 'Year Code'.Year < 1996 and 'This Field' = "These Words" then

 

and a few other combinations but they all failed and messed up the > 1996 results.

3 replies

null
    • Fred
    • 3 yrs ago
    • Reported - view

    your logic is correct, to extend the search you just add "and". Can you post the exact code you are using and why it is not working?

    • Davie
    • 3 yrs ago
    • Reported - view

    Thanks Fred.

    if 'Year Code'.Year < 1996 and 'Film Location' = "Mounted Transparencies" then
    'Year Code'.'Year Code' + 'Month Code'.'Month Code' + Day + 'Day Sequence'
    else
    if 'Year Code'.Year < 1996 then
    'Year Code'.'Year Code' + "-" + Folder.Book + "-" + Page
    else
    'Year Code'.'Year Code' + 'Month Code'.'Month Code' + Day + 'Day Sequence'
    end
    end

     

    If I have a pre 1996 date and the Film Location field is set to Mounted Transparencies I should get the result in ABCD format. However it returns the AB-C-D format (so ingnoring the 'AND').

    Post 1996 gives me the correct ABCD formay so the second section of the script works, as does the last part for pre 1996 where I get AB-C-D returns.

     

    My 'Film Location' field is set as a Choice field where I choose from four options. Is there something here I don't know about?

    • Davie
    • 3 yrs ago
    • Reported - view

    Ah ha! Funny how writing the prblem and explaining it sometimes gets you thinking.

     

    So yes, the Choice field needs treated differently. "Mounted Transparencies" is the second choice so I tried

     

    if 'Year Code'.Year < 1996 and 'Film Location' = 2 then

     

    and it works perfectly.

     

    Thanks