PadStartTrim

jdubs edited this page Oct 21, 2016 · 1 revision

Table of Contents

Overview

Pads the beginning of a variable with characters and trims the return value to the length specified.

Parameters

SpecName (multiple) The name of the variable for operation result assignment

Count (multiple) The variable containing the number of total characters and the returned length of the value

Character (constant) The character to pad

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

Synopsis

Padding adds the specified character to the beginning of the variable value for the length of the Count and trims the result to the length of the Count. For example, if you pad "Four51" with "." for a count of 10 the result would be "....Four51"

Source Code

public static void PadStart(string SpecName, object Count, object Character, object ErrorMessage)
{
	Break();
	try
	{
		var text = Variable(SpecName).Value;
		var pad = text.Length + (int)N(Count);
		Variable(SpecName).Value = text.PadLeft(pad, Convert.ToChar(Character)).Substring(Math.Max((int)N(Count) - text.Length, 0));
	}
	catch (Exception ex)
	{
		throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
	}
}

Referenced Methods

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.