June 20, 200718 yr Hi, I'm having trouble completing a script that will go through a table and check off in the radio button. The field I'm investigating is state abbreviations where the radio button "US Resident" will be marked off as 'Yes' or 'No.' The times that I have tried to run the script has not produced the intended result. Loop Go to Record/Request/Page [First] If[tour::Partner State="AL" or "AK" or "AS" or "AZ" or "CA" or "CO" or "CT" or"DE" or "DC" or "FM" or "FL" or "GA" or "GU" or "HI" or "ID" or "IL" or "IN" or "IA" or "KS" or "KY" or "LA" or "MA" or "MH" or "MD" or "MA" or "MI" or "MN" or "MS" or "MO" or "MT" or "NE" or "NV" or "NH" or "NJ" or "NM" or "NY" or "NC" or "ND" or "MP" or "OH" or "OK" or "OR" or "PW" or "PA" or "PR" or "RI" or "RI" or "SC" or "SD" or "TN" or "TX" or "UT" or "VT" or "VI" or "VA" or "WA" or "WV" or "WI" or "WY" Set Field [tour::US Resident; tour:="Yes"] Else If[ doubttour::Partner State ≠ "AL" or "AK" or "AS" or "AZ" or "CA" or "CO" or "CT" or"DE" or "DC" or "FM" or "FL" or "GA" or "GU" or "HI" or "ID" or "IL" or "IN" or "IA" or "KS" or "KY" or "LA" or "MA" or "MH" or "MD" or "MA" or "MI" or "MN" or "MS" or "MO" or "MT" or "NE" or "NV" or "NH" or "NJ" or "NM" or "NY" or "NC" or "ND" or "MP" or "OH" or "OK" or "OR" or "PW" or "PA" or "PR" or "RI" or "RI" or "SC" or "SD" or "TN" or "TX" or "UT" or "VT" or "VI" or "VA" or "WA" or "WV" or "WI" or "WY" or "FC" = (tour::US Resident = "No") End IF Go to Record/Request/Page [Next] End Loop
June 20, 200718 yr Okay: a) Each and every one of your comparisons needs to have the field name next to it, e.g: tour::Partner state = "AL" or tour::Partner state="AK" ... but that takes forever, so instead use this: If[ PatternCount( List( "AL" ; "AK"; "AS" ; "AZ" ; "AZ" ; "CA" ; ... etc ) ; tour::Partner State)] Your set Field Looks Funny -- is tour:: a typo? c) I'm not sure what happened to your second else if statement, seems to kind of just fad after WY... i mean what's with: "FC" = (tour::US Resident = "No" )? d) Your loop doesn't seem to terminate anywhere? In the Go to Record / Request / Page script step setup, make sure you check, exit after last (its located down the bottom when you are setting the step up). Oh and e) Go to First Record should be outside the loop (i.e. before the loop starts) Let me know how you get on. Edited June 20, 200718 yr by Guest
June 21, 200718 yr GenX pretty well covered the apparent problems with your script as posted. A couple of further ideas: 1. Since your Else If statement doesn't really add anything to your If statement -- it's just the negation of it as far as I can tell -- it's not necessary. A plain Else will do. E.g., it's not necessary to say: If [a = a] Set Field[answer;"yes"] Else If [a <> a] Set Field[answer;"no"] End If ## It's simpler / more efficient to write it: If [a = a] Set Field[answer;"yes"] Else Set Field[answer;"no"] End If ## Some people might write the whole thing in one step: Set Field[answer; Case(a = a;"yes";"no")] 2. You may already have your list of states in a value list (let's say "States"). If so, there is a function you can use to compare, similar to what GenX posted: If[ PatternCount( ValueListItems(Get(FileName);"States") ; tour::Partner State)] Another approach would be to make a table with one record for each state. You could then compare your tour::Partner State to this table. Possible advantages of this structure: ease of maintenance and flexibility.
July 12, 200718 yr Author Sorry I haven't responded earlier. "FC" is "Foreign Country." I tried running the script but the it only came up with all the records that have "FC" in the Partner State field. Even when Partner State equals any of the state abbreviations, it doesn't check in the radio box as 'Yes.'
Create an account or sign in to comment