Bill_misc_IT Posted November 14 Posted November 14 I have a FMP solution that is used to print box labels for our products, prior to shipping to customers. We have many layouts, which represent the label format for each customer's specific requirements. For context, the layouts are named as "Barcode-" and a customer code. For example: Customer Name = Magna Customer code = MAG Layout name = "Barcode-MAG" If a customer does not have a specific requirement, we default to a layout named "Barcode-Default". Currently, we have a printing script, with the following steps, which are used to "check for a customer specific layout" and revert to the default layout, if none exists. The steps (which work) are: # GO TO CUSTOMER SPECIFIC LABEL FORMAT Go to Layout [ "Barcode-" & $$BCLayoutName ; Animation: None ] If [ Get( LastError ) ] Go to Layout [ “Barcode-Default” (FINAL INSPECTION SHEET) ; Animation: None ] End If I'm trying to add another step to the logic, which checks for a part specific layout. In this case, let's call the layout "Barcode-MAG 24". I would like the sequence to follow the below logic: Check for part specific layout. i.e, "Barcode-MAG 24" If none found (error), then check for customer specific layout. i.e. "Barcode-MAG" If none found (error), then go to for default layout. i.e. "Barcode-Default" I created the below steps, however, it is not working. I believe that my use of Else if is incorrect, but wanted to get some help with best practices before I go further. # GO TO CUSTOMER SPECIFIC LABEL FORMAT-NEW | BCC-2024/11/12 Go to Layout [ "Barcode-" & $$BCLayoutMISCID ; Animation: None ] If [ Get( LastError ) ] Go to Layout [ "Barcode-" & $$BCLayoutName ; Animation: None ] Else If [ Get( LastError ) ] Go to Layout [ “Barcode-Default” (FINAL INSPECTION SHEET) ; Animation: None ] End If Please advise?
comment Posted November 14 Posted November 14 To answer your question as asked: I don't see a place for an Else If clause here. It's just a couple of nested Ifs: Go to Layout [ "Barcode-" & $$BCLayoutMISCID ] If [ Get ( LastError ) ] Go to Layout [ "Barcode-" & $$BCLayoutName ] If [ Get ( LastError ) ] Go to Layout [ "Barcode-Default" ] End If End If Side note: do you really need global ($$)variables for this? However, I think that instead of trying blindly a succession of layout names and testing for error, I would prefer to calculate the layout name we want to go to and go to it directly. To do this, we can check if each proposed layout name appears in the list of layouts we can get from the LayoutNames() function - something like: Let ( [ all = LayoutNames ( "") ; part = "Barcode-" & $partCode ; cust = "Barcode-" & $custCode ] ; Case ( not IsEmpty ( FilterValues ( part ; all ) ) ; part ; not IsEmpty ( FilterValues ( cust ; all ) ) ; cust ; "Barcode-Default" ) ) or perhaps more succinctly: Let ( [ candidateLayouts = List ( "Barcode-" & $partCode ; "Barcode-" & $custCode ; "Barcode-Default" ) ; existingLayouts = FilterValues ( candidateLayouts ; LayoutNames ( "" ) ) ] ; GetValue ( existingLayouts ; 1 ) ) Caveat: untested.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now