Skip to content

Code39FullASCII

jdubs edited this page Oct 21, 2016 · 1 revision

Table of Contents

Overview

Applies required format to value to create usable Code 39 Barcode while allowing the full ASCII character set.

Parameters

SpecName (constant) The variable containing the input to be converted. Proper Code39 font must be applied in the template.

ErrorMessage (multiple | optional) The error message to return when any error occurs.

Synopsis

This method follows the specifications of the base Code 39 barcode. The full ASCII character set can be printed in accordance with ISO 646. Each character is encoded using combinations of two symbol characters made up of one of the four Code 39 characters (+ $ % / ) followed by one of the 26 Code 39 barcode alphabetic characters.

Source Code

public static void Code39FullASCII(string SpecName, object ErrorMessage)
{
	Break();
	try
	{
		char[] chars = Variable(SpecName).Value.ToCharArray();
		string barcode = String.Empty;

		for (int i = 0; i <= chars.GetUpperBound(0); i++)
		{
			double value = Convert.ToInt32(chars[i]);
			if (Char.IsNumber(chars[i]) || Char.IsUpper(chars[i]) || value == 45 || value == 46)
				barcode += chars[i].ToString();
			else if (value == 0)
				barcode += "%U";
			else if (value >= 1 && value <= 26)
				barcode += "$" + ((char)(value + 64)).ToString();
			else if (value >= 27 && value <= 31)
				barcode += "%" + ((char)(value + 38)).ToString();
			else if (value == 32)
				barcode += "_";
			else if (value >= 33 && value <= 44)
				barcode += "/" + ((char)(value + 32)).ToString();
			else if (value == 47)
				barcode += "/O";
			else if (value == 58)
				barcode += "/Z";
			else if (value >= 59 && value <= 63)
				barcode += "%" + ((char)(value + 11)).ToString();
			else if (value == 64)
				barcode += "%V";
			else if (value >= 91 && value <= 95)
				barcode += "%" + ((char)(value - 16)).ToString();
			else if (value == 96)
				barcode += "%W";
			else if (value >= 97 && value <= 122)
				barcode += "+" + ((char)(value - 32)).ToString();
			else if (value >= 123 && value <= 126)
				barcode += "%" + ((char)(value - 43)).ToString();
			else if (value == 127)
				barcode += "%T";
			else
				throw new Four51ActionsException("An invalid character not in the ASCII table was referenced.");
		}

		Variable(SpecName).Value = String.Format("*{0}*", barcode);
	}
	catch (Exception ex)
	{
		throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
	}
}

Referenced Methods

Clone this wiki locally