Top Prev Next Up Down

LeftC

Push the result to left. Because we are working with 21-bit characters and all indexing is based on these 21-bit characters.

function leftC(value:CFix;length:Integer;pad:CFix:=CFix_Space) return CFix;

function leftC(value:String;length:Integer;pad:String:=" ") return String;

function leftC(value:CVar;length:Integer;pad:CFix:=CFix_Space) return CVar;

Examples:

001| v10:String:="1234567890";
002| w:String:=(3=>'3',4=>'4',5=>'5');
003| x8:String:=" ABC ";
004| y14:String:="abcdefghijklmn";
005| y15:String:="abcdefghijklmnU";
006| z:String(1 .. 0);

[1] Ada.Text_IO.Put_Line ( "leftC(y14,10).>" & leftC(y14,10) & "<");
  result: leftC(y14,10).>efghijklmn<
[2] Ada.Text_IO.Put_Line ( "leftC(y14,14).>" & leftC(y14,14) & "<");
  result: leftC(y14,14).>abcdefghijklmn<
[3] Ada.Text_IO.Put_Line ( "leftC("""",10,"""").>" & leftC("",10,"") & "<");
  result: leftC("",10,"").>����������<
[4] Ada.Text_IO.Put_Line ( "leftC(y14,15).>" & leftC(y14,15) & "<");
  result: leftC(y14,15).>abcdefghijklmn <
[5] Ada.Text_IO.Put_Line ( "leftC(y14,18,"" !"")>" & leftC(y14,18," !") & "<");
  result: leftC(y14,18," !")>abcdefghijklmn !<
  The first unit in the pad maybe duplicated to get the result length, in this case it is the space.
  Store data in a way to keep the first unit of value as the first unit.