Barcode.SetOptions
------------------

Sets options for barcode creation.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Barcode](component_Barcode.md) | [4.3](newinversion43.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Barcode.SetOptions" { ; Option1; Option2; Option3 } ) 

**MBS**( **"Barcode.SetOptions";** /\* Sets options for barcode creation. \*/  
**$Option1**; /\* Optional; The first option.e.g. 1 \*/   
**$Option2**; /\* Optional; The second option.e.g. 1 \*/   
**$Option3**) /\* Optional; The third option.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Option1 | The first option. | 1 | Optional |
| Option2 | The second option. | 1 | Optional |
| Option3 | The third option. | 1 | Optional |

### Result

Returns OK.

### Description

Sets options for barcode creation.  
Creating a barcode will reset those options to zero for next barcode.  
  
For QRCode:   
Option1 is the ECC Level with values from 1 = low, 2 = middle, 3 = better, 4 high. Default is low.  
Option2 is version code from 1 to 40. Default is 0 to auto select.  
For MicroQR you can use ECC Level 1 to 3 as 4 is not supported.   
  
For Data Matrix:  
Option2 size from 1 to 30. 0 is auto. See table in zint manual pdf.  
Option3 can be 100 to force square size.  
  
e.g. below we set option3 to 100 to square, output options to 16 for reader init added and we pass some hex encoded characters in the JSON for [Barcode.GenerateJSON](BarcodeGenerateJSON.md) function:  
{  
| "Symbology": | "DataMatrix", |
|---|---|
| "Scale": | 4, |
| "Option3": | 100, |
| "OutputOptions": | 16, |
| "Text": | "\[)&gt;\\u001e06\\u001d12P4992\\u001d\\u001e\\u0004" |

}  
  
For Code 39:  
You can set Option2 to 1 to add module 43 checksum.  
  
For MaxiCode:  
Option 1 is the mode.  
  
For PDF 417:  
Option 1 is a number between 0 and 8 where the number of codewords used for check information is determined by 2^(value + 1).   
Option 2 is the number of columns between 1 and 30.  
  
See also [Barcode.DrawBarcode](BarcodeDrawBarcode.md), [Barcode.WriteFile](BarcodeWriteFile.md) and [Barcode.Generate](BarcodeGenerate.md).  
### Examples

Set better ECC level for QRCode:

 MBS ( "Barcode.SetOptions"; 3)  
Set square option for data matrix:

 MBS ( "Barcode.SetOptions"; 0; 0; 100 )  
Create QRCode with UTF-8 and size 10:

 Set Field \[Barcode Generation::Image ; ""\]  
\#Better error correction and size 10   
Set Variable \[$r ; Value:MBS ( "Barcode.SetOptions"; 3; 10 )\]  
\#Generate QRCode with UTF-8   
Set Variable \[$img ; Value:MBS ("[Barcode.Generate](BarcodeGenerate.md)"; "QRCode"; Barcode Generation::Text ; 0; 0; 0; 1; 0; 1; "UTF-8")\]  
If \[GetAsNumber($img ) &gt; 0\]  
 Set Field \[Barcode Generation::Image ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $img ; "barcode.png")\]  
 Set Variable \[$r ; Value:MBS ( "[GMImage.Release](GMImageRelease.md)"; $img )\]  
End If  
Create a data matrix barcode with size 10 and return as container:

 Let ( \[   
// set options for Size 10 (32x32) square for data matrix  
r = MBS ("Barcode.SetOptions"; 0; 10; 100);  
// create a data matrix barcode  
p = MBS ("[Barcode.Generate](BarcodeGenerate.md)"; "DATAMATRIX"; "12818670,3,1" ; 0; 0; 0; 4);  
// success?  
e1 = MBS ("IsError");  
// save as PNG  
image = MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; p; "barcode.png" );  
// success?  
e2 = MBS ("IsError");  
// free image from memory  
r = MBS ("[GMImage.Release](GMImageRelease.md)"; p)  
// return container if no error  
\]; If(e1 = 0 and e2 = 0; image; "") )  
Create Maxicode with mode 3:

 Set Variable \[ $p ; Value: "196LS97TF826004" // primary text \]   
Set Variable \[ $t ; Value: "1Z42015596UPSN123W123456/11NLEEDS" // second text \]   
Set Variable \[ $r ; Value: MBS ("Barcode.SetOptions"; 3) \]   
Set Variable \[ $r ; Value: MBS ("[Barcode.SetPrimary](BarcodeSetPrimary.md)"; $p ) \]   
Set Variable \[ $img ; Value: MBS ("[Barcode.Generate](BarcodeGenerate.md)"; "maxicode"; $t ) \]  
### See also

- [Barcode.DrawBarcode](BarcodeDrawBarcode.md)
- [Barcode.Generate](BarcodeGenerate.md)
- [Barcode.GenerateJSON](BarcodeGenerateJSON.md)
- [Barcode.GetOption](BarcodeGetOption.md)
- [Barcode.SetOption](BarcodeSetOption.md)
- [Barcode.SetPrimary](BarcodeSetPrimary.md)
- [Barcode.WriteFile](BarcodeWriteFile.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)
- [IsError](IsError.md)

### Example Databases

- [Barcode/EPC-QR-Code](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/EPC-QR-Code.shtml#1ScriptAnchor_)
- [Barcode/Generate vCard QR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Generate%20vCard%20QR.shtml#12930FieldAnchor_)
- [Barcode/Swiss QR-Code for invoices/ISO20022 QR v2.3](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Swiss%20QR-Code%20for%20invoices/ISO20022%20QR%20v2.3.shtml#1ScriptAnchor_)
- [Barcode/Swiss QR-Code for invoices/Swiss QR-Code for invoices ISO 20022](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Swiss%20QR-Code%20for%20invoices/Swiss%20QR-Code%20for%20invoices%20ISO%2020022.shtml#11ScriptAnchor_)
- [DynaPDF/Swiss QRCode](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Swiss%20QRCode.shtml#2ScriptAnchor_)

### Blog Entries

- [Generate EPC-QR-Code in FileMaker](https://www.mbsplugins.de/archive/2021-01-26/Generate_EPC-QR-Code_in_FileMa/monkeybreadsoftware_blog_filemaker)
- [Swiss QR-Codes for invoices as vector graphics](https://www.mbsplugins.de/archive/2020-06-12/Swiss_QR-Codes_for_invoices_as/monkeybreadsoftware_blog_filemaker)
- [QR Codes for Invoices in Switzerland](https://www.mbsplugins.de/archive/2017-12-20/QR_Codes_for_Invoices_in_Switz/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.3pr4](https://www.mbsplugins.de/archive/2014-08-03/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2018, Seite 29](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)
- [Ausgabe 5/2018, Seite 27](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)

This function is free to use.

Created 18th August 2014 , last changed 17th November 2022

  
[Barcode.SetOption](BarcodeSetOption.md) - [Barcode.SetPrimary](BarcodeSetPrimary.md)

[HTML Version](BarcodeSetOptions.shtml)