'##############
'Matrix Script
'##############

{macro:Matrix_init}

	-1 (S.L.Matrix_RefreshCursor)
	(L.S.Year) 2001 - 0.01 max 0.0001 * 971 (M.V.NrSpecRandom) 1 + * (S.L.Matrix_Fehlerpixel)

	-1 (S.L.matrix_steckschild_Termindex)
	0 (S.L.matrix_steckschild_vis)
{end}

{trigger:ai_scheduled_settarget}

	(L.$.SetLineTo) (S.$.Matrix_Linie)
	(L.L.AI_target_index) s0 (M.V.GetTerminusCode) s1
	1000 >
	{if}
		l1 1000 - (S.L.matrix_steckschild_index)
		l0 (S.L.matrix_steckschild_Termindex)
		0 (S.L.IBIS_TerminusIndex) s2
	{else}
		l0 (S.L.IBIS_TerminusIndex) s2
		-1 (S.L.matrix_steckschild_Termindex)
		-1 (S.L.Matrix_TerminusIndex_Last)

		l0 6 (M.V.GetTerminusString) $StrToFloat s1
		l1 1000 >
		{if}
			l1 1000 - (S.L.matrix_steckschild_index)
			l0 (S.L.matrix_steckschild_Termindex)			
		{endif}
	{endif}
	(M.L.matrix_setsteckschild)

	l2 (M.V.GetTerminusCode) (S.L.IBIS_TerminusCode)

	1 (S.L.matrix_refresh_seitenschild)

{end}

{trigger:matrix_seitenschildklemme_drag}
	(L.S.mouse_y) -300 / (L.L.matrix_seitenschildklemme) + (S.L.matrix_seitenschildklemme) s0
	l0 0 <
	{if}
		0 (S.L.matrix_seitenschildklemme)
	{endif}
	l0 0.7 >
	{if}
		(L.L.matrix_seitenschild_refresh) 0 =
		{if}
			1 (S.L.matrix_seitenschild_refresh)
			(T.L.ev_fahrertuer_auf)
			(L.$.Matrix_Seitenschild) "" $=
			{if}
				1 (S.L.matrix_refresh_seitenschild)
			{else}
				"" (S.$.Matrix_Seitenschild)
			{endif}
		{endif}
	{endif}
	l0 1 >
	{if}
		1 (S.L.matrix_seitenschildklemme)
	{endif}
{end}

{trigger:matrix_seitenschildklemme_off}
	(L.L.matrix_seitenschildklemme)
	0.3 >
	{if}
		(T.L.ev_fahrertuer_zu)
	{endif}
	0 (S.L.matrix_seitenschildklemme)
	(S.L.matrix_seitenschild_refresh)
{end}

{trigger:bus_matrix_change_steckschild}
	(L.L.matrix_steckschild_index) 1 + (S.L.matrix_steckschild_index)
	1000 + (M.V.GetTerminusIndex) (S.L.matrix_steckschild_Termindex)

	(M.L.matrix_setsteckschild)
	(M.L.matrix_refreshIntIndex)
{end}

{macro:matrix_setsteckschild}
	(L.L.matrix_steckschild_Termindex) s0
	0 >= 
	{if}
		l0 6 (M.V.GetTerminusString) (S.$.Matrix_SchildFrnt)
		1 $SetLengthL $StrToFloat 1 max (S.L.matrix_steckschild_vis)
		"..\..\Anzeigen\SteckSchilder\" (L.$.Matrix_SchildFrnt) $+ (S.$.Matrix_SchildFrnt)
	{else}
		0 (S.L.matrix_steckschild_index) (S.L.matrix_steckschild_vis)
		""  (S.$.Matrix_SchildFrnt)
	{endif}
{end}

{macro:Matrix_frame}

	(L.L.MatrixType)  0 =
	{if}
		 3 (S.L.Matrix_Abstand)
		 2 (S.L.Matrix_maxSpacing) (S.L.Matrix_maxSpacing_u) (S.L.Matrix_maxSpacing_side) (S.L.Matrix_maxSpacing_side_u)
		 1 (S.L.Matrix_minSpacing)
		40 (S.L.Matrix_maxLinie)
		33 (S.L.Matrix_maxLinie_side)
		27 (S.L.Matrix_maxLinie_Rear)
		"DD-Mod TB26L" (M.V.GetFontIndex) (S.L.Font_0)
		"DD-Mod LNRSMALL.F26" (M.V.GetFontIndex) (S.L.Font_1)
		"DD-Mod SLSmall.F19" (M.V.GetFontIndex) (S.L.Font_0_side) (S.L.Font_1_side)
	{endif}

	(L.L.Matrix_Animation)
	{if}
		(L.L.Matrix_Power) -1 =
		{if}
			(M.L.Matrix_DrawingOn) (M.L.Matrix_DrawingOff)
			0 (S.L.Matrix_Power)
		{endif}
		(L.L.elec_busbar_main) (L.L.Matrix_Power) 0 = &&
		{if}
			0 (S.L.Matrix_Linie_Last)
			1 (S.L.Matrix_Power)
		{endif}
		(L.L.elec_busbar_main) (L.L.Matrix_Power) 2 = &&
		{if}
			(M.L.Matrix_DrawingOn) (M.L.Matrix_DrawingOff)
			1 (S.L.Matrix_Power)
		{endif}
		(L.L.elec_busbar_main) ! (L.L.Matrix_Power) 1 >= &&
		{if}
			(M.L.Matrix_DrawingOn)
			1
			0
			255
			255
			255
			(M.V.STSetColor)	
				
			1
			0
			0
			216 4 *
			27 4 2 * *
			(M.V.STDrawRect)
			(M.L.Matrix_DrawingOff)
			0 (S.L.target_index_int)
			0 (M.V.STNewTex)
			-1 (S.L.Matrix_Power)
		{endif}
	{endif}

	(L.S.TimeGap) (L.L.Matrix_Timer) + (S.L.Matrix_Timer) 3 0.1 + >=
	(L.L.IBIS_TerminusIndex) (L.L.Matrix_TerminusIndex_Last) = &&
	(L.L.Matrix_TerminusAct) 0 > &&
	{if}
		(L.L.Matrix_TerminusAct) (M.V.GetTerminusCode) s0 1000 <
		{if}
			l0 (S.L.Matrix_TerminusCode_Original)
			l0 10000 + s0
		{else}
			l0 1000 + s0
		{endif}
		l0 (M.V.GetTerminusIndex) s1 0 >=
		{if}
			l1 (S.L.IBIS_TerminusIndex)
		{else}
			(L.L.Matrix_TerminusCode_Original) (M.V.GetTerminusIndex) (S.L.IBIS_TerminusIndex)
		{endif}
	{endif}

    (L.L.Matrix_InitState) (S.L.Matrix_InitStateLast) 
    
    (L.L.elec_busbar_main)
	(L.L.Matrix_InitTimer) 0 >= &&
    (L.L.Matrix_InitTimer) 20 < &&
	(L.L.AI) ! &&
    {if}
        (L.L.Matrix_InitTimer) (L.S.Timegap) + (S.L.Matrix_InitTimer)
        s0 15 >
        (L.L.Matrix_InitState) 3 = &&
        {if}
            4 (S.L.Matrix_InitState)
            -1 (S.L.Matrix_Linie_Last) (S.L.Matrix_TerminusIndex_Last)
			"" (S.$.Matrix_TerminusL5)
            "" (S.$.Matrix_TerminusL6)
        {else}
        l0 10 >
        (L.L.Matrix_InitState) 2 = &&
        {if}
			3 (S.L.Matrix_InitState)
			"" (S.$.Matrix_Linie)
			"Adr.1dez-SV6.18" (S.$.Matrix_TerminusL1)
			"8-8-6 - ZD01.01/62" (S.$.Matrix_TerminusL2)
			"Adr.2dez-SV6.18" (S.$.Matrix_TerminusL3)
			"8-8-6 - ZD01.01/62" (S.$.Matrix_TerminusL4)
			"Adr.3" (S.$.Matrix_TerminusL5)
			"SV6.18" (S.$.Matrix_TerminusL6)
			1 (S.L.Matrix_InitStateFont)
			0 (S.L.Matrix_InvertL1) (S.L.Matrix_InvertL2) (S.L.Matrix_InvertL3) (S.L.Matrix_InvertL4) (S.L.Matrix_InvertK1) (S.L.Matrix_InvertK3) (S.L.Matrix_InvertLN1) (S.L.Matrix_InvertLN3)
        {else}
        l0 5 >
        (L.L.Matrix_InitState) 1 = &&
        {if}
            2 (S.L.Matrix_InitState)
        {else}
        l0 0 >
        (L.L.Matrix_InitState) 0 = &&
        {if}
            1 (S.L.Matrix_InitState)
        {endif}
        {endif}
        {endif}
        {endif}
    {endif}
    
    (L.L.elec_busbar_main) !
    {if}
		1 (M.V.STNewTex)
		0 (S.L.Matrix_InitState) (S.L.Matrix_InitStateLast) (S.L.Matrix_InitTimer)
    {endif}
	
	(L.L.IBIS_Linie_Complex) s0 (L.L.Matrix_Linie_Last) = !
	(L.L.IBIS_Linie_Suffix) (L.L.Matrix_Linie_Suffix) = ! ||
	(L.L.elec_busbar_main) &&
	{if}
		l0 100 / trunc s1
		l1 0 =
		{if}
			""
			"" (S.$.Matrix_TerminusL5)
			"" (S.$.Matrix_TerminusL6)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
		{else}
			"" (S.$.Matrix_TerminusL5)
			"" (S.$.Matrix_TerminusL6)
			l1 trunc $IntToStr
			(S.L.Matrix_TerminusIndex_Last)
		{endif}
		
		(S.$.Matrix_Linie)

		(L.L.IBIS_Linie_Suffix)  1 = {if} "E" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces  $+ {endif}
		(L.L.IBIS_Linie_Suffix)  2 = {if} "^" {endif}
		(L.L.IBIS_Linie_Suffix)  3 = {if} "&" {endif}
		(L.L.IBIS_Linie_Suffix)  4 = {if} (L.$.Matrix_Linie) "N" $+ {endif}
		(L.L.IBIS_Linie_Suffix)  5 = {if} "S" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix)  6 = {if} "A" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix)  9 = {if} "E" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 10 = {if} (L.$.Matrix_Linie) "E" $+ {endif}
		(L.L.IBIS_Linie_Suffix) 11 = {if} "D" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 12 = {if} "C" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 13 = {if} "B" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 14 = {if} "A" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 15 = {if} "N" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 22 = {if} "R" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 23 = {if} "S" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 24 = {if} "S" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 25 = {if} "U" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 26 = {if} "U" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 27 = {if} "M" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 28 = {if} "M" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 30 = {if} (L.$.Matrix_Linie) "S" 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 31 = {if} (L.$.Matrix_Linie) "U" 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 32 = {if} (L.$.Matrix_Linie) "M" 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 33 = {if} "0" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 34 = {if} "00" (L.$.Matrix_Linie) 1 $SetLengthR $+ {endif}
		(L.L.IBIS_Linie_Suffix) 35 = {if} "N" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 36 = {if} "X" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 37 = {if} "{" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 38 = {if} "}" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 39 = {if} "|" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 40 = {if} "$" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 41 = {if} "a" {endif}
		(L.L.IBIS_Linie_Suffix) 42 = {if} "©" {endif}
		(L.L.IBIS_Linie_Suffix) 43 = {if} "b" {endif}
		(L.L.IBIS_Linie_Suffix) 44 = {if} "u" {endif}
		(L.L.IBIS_Linie_Suffix) 45 = {if} "c" {endif}
		(L.L.IBIS_Linie_Suffix) 46 = {if} "§" {endif}
		(L.L.IBIS_Linie_Suffix) 47 = {if} "*" {endif}
		(L.L.IBIS_Linie_Suffix) 48 = {if} "q" {endif}
		(L.L.IBIS_Linie_Suffix) 49 = {if} "d" {endif}
		(L.L.IBIS_Linie_Suffix) 50 = {if} "e" {endif}
		(L.L.IBIS_Linie_Suffix) 55 = {if} "SEV" {endif}
		(L.L.IBIS_Linie_Suffix) 56 = {if} "RE" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 57 = {if} "RB" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}
		(L.L.IBIS_Linie_Suffix) 58 = {if} "EV" (L.$.Matrix_Linie) 2 max $SetLengthR $RemoveSpaces $+ {endif}

		(L.L.IBIS_Linie_Suffix) (S.L.Matrix_Linie_Suffix)

		$RemoveSpaces (S.$.Matrix_Linie)
	{endif}

	(L.L.IBIS_TerminusIndex) s0 (L.L.Matrix_TerminusIndex_Last) s1 = !
	(L.L.elec_busbar_main) &&
	{if}
		l0 13 (M.V.GetTerminusString) $length 0 > 
		{if}
			l0 13 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL1)
			l0 14 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL2)
			l0 15 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL3)
			l0 16 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL4)
			l0 22 (M.V.GetTerminusString) $RemoveSpaces (M.L.Matrix_CapitalizeString) (S.$.Matrix_TerminusL5)
		{else}
			l0  1 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL1)
			l0  2 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL2)
			l0  3 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL3)
			l0  4 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL4)
			l0 22 (M.V.GetTerminusString) $RemoveSpaces (M.L.Matrix_CapitalizeString) (S.$.Matrix_TerminusL5)
		{endif}
		
		(L.$.Matrix_TerminusL5) "" 0 $=
		{if}
			0 (S.$.Matrix_TerminusL5)
		{else}
			1 (S.$.Matrix_TerminusL5)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
			"" (S.$.Matrix_Linie)
		{endif}
		
		(L.$.Matrix_TerminusL6) "" 0 $=
		{if}
			0 (S.$.Matrix_TerminusL6)
		{else}
			1 (S.$.Matrix_TerminusL6)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
			"" (S.$.Matrix_Linie)
		{endif}
		
		0 s0
		(L.$.Matrix_TerminusL1) 1 $cutEnd 1 $SetLengthR "#" $= {if} 1 s0 {endif}
		(L.$.Matrix_TerminusL1) 2 $cutEnd 1 $SetLengthR "#" $= {if} 2 s0 {endif}
		(L.$.Matrix_TerminusL1) 3 $cutEnd 1 $SetLengthR "#" $= {if} 3 s0 {endif}
		(L.$.Matrix_TerminusL1) 4 $cutEnd 1 $SetLengthR "#" $= {if} 4 s0 {endif}
		(L.$.Matrix_TerminusL1) 5 $cutEnd 1 $SetLengthR "#" $= {if} 5 s0 {endif}
		(L.$.Matrix_TerminusL1) 6 $cutEnd 1 $SetLengthR "#" $= {if} 6 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL1) l0 $SetLengthR (S.$.Matrix_TerminusL5)
			(L.$.Matrix_TerminusL1) l0 1 + $cutEnd (S.$.Matrix_TerminusL1)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
			1 (S.L.Matrix_MinSpacing)
			3 (S.L.Matrix_MaxSpacing)
			"" (S.$.Matrix_Linie)
		{endif}
			
		0 s0
		(L.$.Matrix_TerminusL2) 1 $cutEnd 1 $SetLengthR "#" $= {if} 1 s0 {endif}
		(L.$.Matrix_TerminusL2) 2 $cutEnd 1 $SetLengthR "#" $= {if} 2 s0 {endif}
		(L.$.Matrix_TerminusL2) 3 $cutEnd 1 $SetLengthR "#" $= {if} 3 s0 {endif}
		(L.$.Matrix_TerminusL2) 4 $cutEnd 1 $SetLengthR "#" $= {if} 4 s0 {endif}
		(L.$.Matrix_TerminusL2) 5 $cutEnd 1 $SetLengthR "#" $= {if} 5 s0 {endif}
		(L.$.Matrix_TerminusL2) 6 $cutEnd 1 $SetLengthR "#" $= {if} 6 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL2) l0 $SetLengthR (S.$.Matrix_TerminusL6)
			(L.$.Matrix_TerminusL2) l0 1 + $cutEnd (S.$.Matrix_TerminusL2)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
			1 (S.L.Matrix_MinSpacing)
			3 (S.L.Matrix_MaxSpacing)
			"" (S.$.Matrix_Linie)
		{endif}
			
		0 s0
		(L.$.Matrix_TerminusL5) 1 $cutEnd 1 $SetLengthR "#" $= {if} 1 s0 {endif}
		(L.$.Matrix_TerminusL5) 2 $cutEnd 1 $SetLengthR "#" $= {if} 2 s0 {endif}
		(L.$.Matrix_TerminusL5) 3 $cutEnd 1 $SetLengthR "#" $= {if} 3 s0 {endif}
		(L.$.Matrix_TerminusL5) 4 $cutEnd 1 $SetLengthR "#" $= {if} 4 s0 {endif}
		(L.$.Matrix_TerminusL5) 5 $cutEnd 1 $SetLengthR "#" $= {if} 5 s0 {endif}
		(L.$.Matrix_TerminusL5) 6 $cutEnd 1 $SetLengthR "#" $= {if} 6 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL5) l0 $SetLengthR (S.$.Matrix_TerminusL6)
			(L.$.Matrix_TerminusL5) l0 1 + $cutEnd (S.$.Matrix_TerminusL5)
			0 (S.L.Matrix_LineWidth)
			0 (S.L.Matrix_LineWidth_side)
			1 (S.L.Matrix_MinSpacing)
			2 (S.L.Matrix_MaxSpacing)
			"" (S.$.Matrix_Linie)
		{endif}
		
		0 s0
		(L.$.Matrix_TerminusL1) 1 $cutEnd 1 $SetLengthR "~" $= {if} 1 s0 {endif}
		(L.$.Matrix_TerminusL1) 2 $cutEnd 1 $SetLengthR "~" $= {if} 2 s0 {endif}
		(L.$.Matrix_TerminusL1) 3 $cutEnd 1 $SetLengthR "~" $= {if} 3 s0 {endif}
		(L.$.Matrix_TerminusL1) 4 $cutEnd 1 $SetLengthR "~" $= {if} 4 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL1) l0 $SetLengthR (S.$.Matrix_Linie)
			(L.$.Matrix_TerminusL1) l0 1 + $cutEnd (S.$.Matrix_TerminusL1)
		{endif}
		
		0 s0
		(L.$.Matrix_TerminusL1) 1 $cutEnd 1 $SetLengthR "‡" $= {if} 1 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL1) l0 $SetLengthR (S.$.Matrix_TerminusI1)
			(L.$.Matrix_TerminusL1) l0 1 + $cutEnd (S.$.Matrix_TerminusL1)
		{endif}
		
		0 s0
		(L.$.Matrix_TerminusL3) 1 $cutEnd 1 $SetLengthR "‡" $= {if} 1 s0 {endif}

		l0 0 >
		{if}
			(L.$.Matrix_TerminusL3) l0 $SetLengthR (S.$.Matrix_TerminusI2)
			(L.$.Matrix_TerminusL3) l0 1 + $cutEnd (S.$.Matrix_TerminusL3)
		{endif}
				
		(L.$.Matrix_TerminusL2) $length 0 > 
        {if} 
            (L.$.Matrix_TerminusL1) (S.$.Matrix_TerminusL1)
        {else}
            (L.$.Matrix_TerminusL1) (S.$.Matrix_TerminusL1)
        {endif}
		
		(L.$.Matrix_TerminusL4) $length 0 > 
        {if} 
            (L.$.Matrix_TerminusL3) (S.$.Matrix_TerminusL3)
        {else}
            (L.$.Matrix_TerminusL3) (M.L.Matrix_CapitalizeString) (S.$.Matrix_TerminusL3)
        {endif}
		
		(L.$.Matrix_TerminusL1) "" $=
		{if}
			(L.$.Matrix_TerminusL2) (S.$.Matrix_TerminusL1)
			"" (S.$.Matrix_TerminusL2)
		{endif}
		(L.$.Matrix_TerminusL3) "" $=
		{if}
			(L.$.Matrix_TerminusL4) (S.$.Matrix_TerminusL3)
			"" (S.$.Matrix_TerminusL4)
		{endif}
		
		(L.$.Matrix_TerminusL3) 4 $SetLengthR ".bmp" $= s2 0
		(L.$.Matrix_TerminusL3) 4 $SetLengthR ".tga" $= s2 0
		(L.$.Matrix_TerminusL4) 4 $SetLengthR ".bmp" $= s3 0
		(L.$.Matrix_TerminusL4) 4 $SetLengthR ".tga" $= s3 0
        
		l2 l3 ||
		(L.$.Matrix_TerminusL3) "" $= ||
		{if}
			(L.$.Matrix_TerminusL1) (S.$.Matrix_TerminusL3)
			(L.$.Matrix_TerminusL2) (S.$.Matrix_TerminusL4)
		{endif}
		
		(L.$.Matrix_TerminusL1) 2 $SetLengthR "*B" 0 $= {if} (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1) {endif}
		(L.$.Matrix_TerminusL2) 2 $SetLengthR "*B" 0 $= {if} (L.$.Matrix_TerminusL2) 2 $cutEnd (S.$.Matrix_TerminusL2) {endif}
		(L.$.Matrix_TerminusL3) 2 $SetLengthR "*B" 0 $= {if} (L.$.Matrix_TerminusL3) 2 $cutEnd (S.$.Matrix_TerminusL3) {endif}
		(L.$.Matrix_TerminusL4) 2 $SetLengthR "*B" 0 $= {if} (L.$.Matrix_TerminusL4) 2 $cutEnd (S.$.Matrix_TerminusL4) {endif}
		(L.$.Matrix_TerminusL1) 2 $SetLengthR "*M" 0 $= {if} (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1) {endif}
		(L.$.Matrix_TerminusL2) 2 $SetLengthR "*M" 0 $= {if} (L.$.Matrix_TerminusL2) 2 $cutEnd (S.$.Matrix_TerminusL2) {endif}
		(L.$.Matrix_TerminusL3) 2 $SetLengthR "*M" 0 $= {if} (L.$.Matrix_TerminusL3) 2 $cutEnd (S.$.Matrix_TerminusL3) {endif}
		(L.$.Matrix_TerminusL4) 2 $SetLengthR "*M" 0 $= {if} (L.$.Matrix_TerminusL4) 2 $cutEnd (S.$.Matrix_TerminusL4) {endif}

		(L.$.Matrix_TerminusL1) 2 $SetLengthR "*G" 0 $= 
        {if}
			1 (S.L.Matrix_HeightvarG) (S.L.Matrix_Heightvar0)
			0 (S.L.Matrix_HeightvarK)
            (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL3) 2 $SetLengthR "*G" 0 $= 
        {if}
			(L.$.Matrix_TerminusL3) 2 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		0 (S.L.Matrix_InvertL1) (S.L.Matrix_InvertL2) (S.L.Matrix_InvertL3) (S.L.Matrix_InvertL4) (S.L.Matrix_InvertK1) (S.L.Matrix_InvertK3) (S.L.Matrix_InvertLN1) (S.L.Matrix_InvertLN3)
		(L.$.Matrix_TerminusL1) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL1)
			1 (S.L.Matrix_Invert)
            (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
        (L.$.Matrix_TerminusL2) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL2)
			1 (S.L.Matrix_Invert)
            (L.$.Matrix_TerminusL2) 2 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
        (L.$.Matrix_TerminusL3) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL3)
			1 (S.L.Matrix_Invert)
            (L.$.Matrix_TerminusL3) 2 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
        (L.$.Matrix_TerminusL4) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL4)
			1 (S.L.Matrix_Invert)
            (L.$.Matrix_TerminusL4) 2 $cutEnd (S.$.Matrix_TerminusL4)
        {endif}
		(L.$.Matrix_TerminusL2) "" $=
        {if}
            (L.L.Matrix_InvertL1) (S.L.Matrix_InvertL2)
        {endif}
        (L.$.Matrix_TerminusL4) "" $=
        {if}
            (L.L.Matrix_InvertL3) (S.L.Matrix_InvertL4)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*IK" 0 $= 
        {if}
            1 (S.L.Matrix_InvertK1) (S.L.Matrix_InvertK3)
			1 (S.L.Matrix_InvertIK)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*IK" 0 $= 
        {if}
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*IL" 0 $= 
        {if}
            1 (S.L.Matrix_InvertLN1) (S.L.Matrix_InvertLN3)
			1 (S.L.Matrix_InvertIL)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*IL" 0 $= 
        {if}
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL1) 2 $SetLengthR "*K" 0 $= 
        {if}
			1 (S.L.Matrix_HeightvarK) (S.L.Matrix_Heightvar0)
			0 (S.L.Matrix_HeightvarG)
            (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1)
			(L.$.Matrix_TerminusL2) (S.$.Matrix_TerminusL2)
        {endif}
		(L.$.Matrix_TerminusL3) 2 $SetLengthR "*K" 0 $= 
        {if}
            (L.$.Matrix_TerminusL3) 2 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*S1" 0 $= 
        {if}
			1 (S.L.Matrix_maxSpacing)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL2) 3 $SetLengthR "*S1" 0 $= 
        {if}
			1 (S.L.Matrix_maxSpacing_u)
            (L.$.Matrix_TerminusL2) 3 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*S1" 0 $= 
        {if}
			1 (S.L.Matrix_maxSpacing_side)
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL4) 3 $SetLengthR "*S1" 0 $= 
        {if}
			1 (S.L.Matrix_maxSpacing_side_u)
            (L.$.Matrix_TerminusL4) 3 $cutEnd (S.$.Matrix_TerminusL4)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*S2" 0 $= 
        {if}
			2 (S.L.Matrix_maxSpacing)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL2) 3 $SetLengthR "*S2" 0 $= 
        {if}
			2 (S.L.Matrix_maxSpacing_u)
            (L.$.Matrix_TerminusL2) 3 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*S2" 0 $= 
        {if}
			2 (S.L.Matrix_maxSpacing_side)
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL4) 3 $SetLengthR "*S2" 0 $= 
        {if}
			2 (S.L.Matrix_maxSpacing_side_u)
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL4)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*S3" 0 $= 
        {if}
			3 (S.L.Matrix_maxSpacing)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL2) 3 $SetLengthR "*S3" 0 $= 
        {if}
			3 (S.L.Matrix_maxSpacing_u)
            (L.$.Matrix_TerminusL2) 3 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*S3" 0 $= 
        {if}
			3 (S.L.Matrix_maxSpacing_side)
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL4) 3 $SetLengthR "*S3" 0 $= 
        {if}
			3 (S.L.Matrix_maxSpacing_side_u)
            (L.$.Matrix_TerminusL4) 3 $cutEnd (S.$.Matrix_TerminusL4)
        {endif}
		(L.$.Matrix_TerminusL1) 3 $SetLengthR "*S4" 0 $= 
        {if}
			4 (S.L.Matrix_maxSpacing)
            (L.$.Matrix_TerminusL1) 3 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
		(L.$.Matrix_TerminusL2) 3 $SetLengthR "*S4" 0 $= 
        {if}
			4 (S.L.Matrix_maxSpacing_u)
            (L.$.Matrix_TerminusL2) 3 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
		(L.$.Matrix_TerminusL3) 3 $SetLengthR "*S4" 0 $= 
        {if}
			4 (S.L.Matrix_maxSpacing_side)
            (L.$.Matrix_TerminusL3) 3 $cutEnd (S.$.Matrix_TerminusL3)
        {endif}
		(L.$.Matrix_TerminusL4) 3 $SetLengthR "*S4" 0 $= 
        {if}
			4 (S.L.Matrix_maxSpacing_side_u)
            (L.$.Matrix_TerminusL4) 3 $cutEnd (S.$.Matrix_TerminusL4)
        {endif}
	{endif}
	
    (L.L.IBIS_Linie_Complex) (L.L.Matrix_Linie_Last) = !
    (L.L.IBIS_TerminusIndex) s0 (L.L.Matrix_TerminusIndex_Last) s1 = ! ||
    (L.L.Matrix_InitState) (L.L.Matrix_InitStateLast) = ! ||
    (L.L.elec_busbar_main) &&
    {if}
		(L.L.Matrix_Animation)
		{if}
			(L.L.Matrix_IsDrawing)
			{if}
				(M.L.Matrix_DrawingOff)
				0 (M.V.STNewTex)
			{endif}

			(L.L.Matrix_RefreshCursor) 0 <
			{if}
				0 (M.V.STNewTex)
			{endif}
		{endif}
		
		l0 (S.L.Matrix_TerminusAct)
		(L.L.IBIS_Linie_Complex) (S.L.Matrix_Linie_Last)
		(L.L.IBIS_Linie_Suffix) 99 = !
		{if}
			l0 7 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_Bitmapfilename)
			"" $=
			{if}

			(L.L.Matrix_Animation) !
			{if}
				0 (M.V.STNewTex)
			{endif}
			0 (M.V.STLock)

			0
			0
			255
			0
			0
			(M.V.STSetColor)
			
			(L.L.schedule_active) 
			(L.$.IBISPlus_Linie) $length 4 = &&
			(L.L.Matrix_InitState) 4 = &&

			(L.$.Matrix_Linie) "" $=
			{if}
				0 s1 (S.L.Matrix_Xpos)
				0 (S.L.Matrix_LineWidth)
				0 (S.L.Matrix_LineWidth_side)
			{else}

			(L.$.Matrix_Linie) $length 1 - 0 max s6

			(L.$.Matrix_Linie) "/^\" $= {if} "^" (S.$.Matrix_Linie) {endif}
			(L.$.Matrix_Linie) "gh" $= {if} "&" (S.$.Matrix_Linie) {endif}
			
			(L.$.Matrix_Linie) (L.L.Font_0) s0 (M.V.TextLength) l6 + s1
			(L.L.Matrix_maxLinie) >
			{if}
				(L.$.Matrix_Linie) (L.L.Font_1) s0 (M.V.TextLength) l6 + s1
				(L.L.Matrix_maxLinie) >
			{endif}

			(L.L.Matrix_InvertK1) 1 =
			(L.L.Matrix_InvertLN1) 1 = ||			
			{if}
				2 s5
				l1 2 + s1
			{else}
				0 s5
				l1 0 + s1
			{endif}
					
			0
			l5
			0
			l0
			2
			1
			(L.$.Matrix_Linie)
			(M.V.STTextOut)
			
			(L.L.Matrix_Abstand) l1 + (S.L.Matrix_LineWidth)
			
			(L.$.Matrix_Linie) (L.L.Font_0_side) s0 (M.V.TextLength) l6 + s1
			(L.L.Matrix_maxLinie_side) >
			{if}
				(L.$.Matrix_Linie) (L.L.Font_1_side) s0 (M.V.TextLength) l6 + s1
				(L.L.Matrix_maxLinie_side) >
			{endif}
			
			(L.L.Matrix_InvertK1) 1 =
			(L.L.Matrix_InvertLN1) 1 = ||
			{if}
				2 s5
				l1 2 + s1
			{else}
				0 s5
				l1 0 + s1
			{endif}
						
			0
			l5
			28
			l0
			2
			1
			(L.$.Matrix_Linie)
			(M.V.STTextOut)

			(L.L.Matrix_Abstand) l1 + (S.L.Matrix_LineWidth_Side)

			(L.$.Matrix_Linie) (L.L.Font_0_side) s0 (M.V.TextLength) s1
			(L.L.Matrix_maxLinie_Rear) >
			{if}
				(L.$.Matrix_Linie) (L.L.Font_1_side) s0 (M.V.TextLength) s1
			{endif}
			
			28 l1 - l6 / trunc 1 s7
			l1 l6 l7 * + s1
			28 l1 - 2 / trunc s5

			0
			l5
			56
			l0
			2
			l7
			(L.$.Matrix_Linie)
			(M.V.STTextOut)
		{endif}

		0 (M.L.Matrix_Draw)
		1 (M.L.Matrix_Draw)
		0 (M.L.Matrix_Draw_Icon)
		1 (M.L.Matrix_Draw_Icon)
		(M.L.Matrix_Draw_Rear)

		0 (M.V.STUnlock)

		{endif}
	    (L.L.Matrix_TerminusAct) (S.L.Matrix_TerminusIndex_Last)
		(M.L.matrix_refreshIntIndex)
	{endif}
	0 (S.L.Matrix_RefreshCursor)
    {endif}

	(L.L.elec_busbar_main)
	(L.L.Matrix_RefreshCursor) 0 >= &&
	{if}	
    
		0 (M.V.STLock)
		(L.L.Matrix_Animation) !
		{if}
			1 (M.V.STLock)
		{endif}

		(L.L.Matrix_RefreshCursor) 0 =
		{if}
			(M.L.Matrix_DrawingOn)
			(L.L.Matrix_Wait) 1 + 10 % (S.L.Matrix_Wait)
		{endif}
		
		(L.L.Matrix_Wait) !
		{if}
			(M.L.Matrix_PixelRefresh_100)
		{endif}

		(L.L.Matrix_Timer) 0.1 >=
		{if}
			0 (S.L.Matrix_Timer)
		{endif}
 
		0 (M.V.STUnlock)
		(L.L.Matrix_Animation) !
		{if}
			1 (M.V.STUnlock)
			1 (M.V.STFilter)
		{endif}
	{endif}

	"Linienlisten\" (L.$.yard) "_ANX.jpg" $+ $+ (S.$.Matrix_Linelist)
{end}

{macro:Matrix_PixelRefresh_100}
	(M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10)
	(M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10) (M.L.Matrix_PixelRefresh_10)
{end}

{macro:Matrix_PixelRefresh_10}
	(M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3)
	(M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3) (M.L.Matrix_PixelRefresh_x3)
{end}

{macro:Matrix_PixelRefresh_x3}
	0 s0
	(M.L.Matrix_PixelRefresh)
	(L.L.Matrix_RefreshCursor) 1 - (S.L.Matrix_RefreshCursor)
	1 s0
	(M.L.Matrix_PixelRefresh)
	(L.L.Matrix_RefreshCursor) 1 - (S.L.Matrix_RefreshCursor)
	2 s0
	(M.L.Matrix_PixelRefresh)
	(L.L.Matrix_RefreshCursor) 1 - (S.L.Matrix_RefreshCursor)
	3 s0
	(M.L.Matrix_PixelRefresh)
{end}

{macro:Matrix_PixelRefresh}
	(L.L.Matrix_RefreshCursor) 6500 >=
	(L.L.Matrix_RefreshCursor) 0 < ||
	{if}
		0 (S.L.Matrix_Timer)
		(L.L.Matrix_Animation) (L.L.Matrix_RefreshCursor) 0 >= &&
		{if}
			(M.L.Matrix_DrawingOn) (M.L.Matrix_DrawingOff)
			2 (S.L.Matrix_Power)
		{endif}
		-1 (S.L.Matrix_RefreshCursor)
	{else}

		(L.L.Matrix_RefreshCursor) 6500 % 27 / trunc s1
		(L.L.Matrix_RefreshCursor) 6500 % 27 / trunc s1
		(L.L.Matrix_RefreshCursor) 6500 % 27 % s2

		(L.L.Matrix_Animation) 1 =
		{if}
			2 s6
		{else}
			(L.L.Matrix_RefreshCursor) (M.V.NrSpecRandom) 2 * (L.L.Matrix_Fehlerpixel) / s6
		{endif}
		1 <
		{if}
			255 s7
		{else}
		l6 2 <
		{if}
			0 s7
		{else}
			0
			l1
			l2 l0 27 * +
			(M.V.STReadPixel)
			0 (M.V.STGetR) s7
                
			(L.L.Matrix_Invert) 1 =
			{if}
				(L.L.Matrix_HeightvarK) !
				{if}
					l0 0 = l2  0 >= l2 (L.L.Matrix_Height) 2 / 1 - (L.L.Matrix_HeightvarL0) + <= (L.L.Matrix_InvertL1) && && &&
					l0 0 = l2 (L.L.Matrix_Height) 2 / (L.L.Matrix_HeightvarL0) + >= l2 (L.L.Matrix_Height) <= (L.L.Matrix_InvertL2) && && && ||
					l1 (L.L.Matrix_LineWidth) >= &&
					l0 1 = l2  0 >= l2 (L.L.Matrix_Height_side) 2 / <= (L.L.Matrix_InvertL3) && && &&
					l0 1 = l2 (L.L.Matrix_Height_side) 2 / >= l2 (L.L.Matrix_Height_side) <= (L.L.Matrix_InvertL4) && && && ||
					l1 (L.L.Matrix_LineWidth_Side) >= && ||
				{else}
					l0 0 = l2  0 >= l2 (L.L.Matrix_Height) 2 / 1 - (L.L.Matrix_HeightvarL0) - <= (L.L.Matrix_InvertL1) && && &&
					l0 0 = l2 (L.L.Matrix_Height) 2 / (L.L.Matrix_HeightvarL0) - >= l2 (L.L.Matrix_Height) <= (L.L.Matrix_InvertL2) && && && ||
					l1 (L.L.Matrix_LineWidth) >= &&
					l0 1 = l2  0 >= l2 (L.L.Matrix_Height_side) 2 / <= (L.L.Matrix_InvertL3) && && &&
					l0 1 = l2 (L.L.Matrix_Height_side) 2 / >= l2 (L.L.Matrix_Height_side) <= (L.L.Matrix_InvertL4) && && && ||
					l1 (L.L.Matrix_LineWidth_Side) >= && ||
				{endif}
				{if}
					l7 255 = {if} 0 s7 {else} 255 s7 {endif}
				{endif}
			{endif}
			(L.L.Matrix_InvertIK) 1 =
			{if}
				l0 0 = l2 28 >= l2 (L.L.Matrix_Height) 2 + <= (L.L.Matrix_InvertK1) && && &&
				{if}
					l7 255 = {if} 0 s7 {else} 255 s7 {endif}
				{endif}
				(L.L.Matrix_InvertK1) 1 =
				{if}
					l7 255 = {if} 0 s7 {else} 255 s7 {endif}
				{endif}
			{endif}
			(L.L.Matrix_InvertIL) 1 =
			{if}
				l0 0 = l2 0 >= l2 (L.L.Matrix_Height) <= (L.L.Matrix_InvertLN1) && && &&
				l1 (L.L.Matrix_LineWidth) >= &&
				l0 1 = l2 0 >= l2 (L.L.Matrix_Height_side) <= (L.L.Matrix_InvertLN1) && && &&
				l1 (L.L.Matrix_LineWidth_Side) >= && ||
				{if}
					l7 255 = {if} 0 s7 {else} 255 s7 {endif}
				{endif}
				(L.L.Matrix_InvertLN1) 1 =
				{if}
					l7 255 = {if} 0 s7 {else} 255 s7 {endif}
				{endif}
			{endif}
                
            (L.L.Matrix_InitState) 1 =
            {if}
                0 s7
            {endif}
            (L.L.Matrix_InitState) 2 =
            {if}
                255 s7
            {endif}
		{endif}
		{endif}
		1
		l7
		255
		255
		255
		(M.V.STSetColor)

		1
		l7
		255
		255
		255
		(M.V.STSetColor)

		1
		l1 4 * s4
		l2 l0 27 * + 4 * s5
		l4 4 +
		l5 4 +
		(M.V.STDrawRect)

		(L.L.Matrix_RefreshCursor) 1 + (S.L.Matrix_RefreshCursor)
	{endif}
{end}

{macro:Matrix_Draw}
(M.L.Matrix_Data)

	(L.L.CoD_MatrixIndex) 0 =
	{if}
		(L.$.Matrix_TerminusL1) (S.$.Matrix_TerminusString1)
		(L.$.Matrix_TerminusL2) (S.$.Matrix_TerminusString2)
		(L.L.Matrix_minSpacing) (S.L.Matrix_SpacingMin)
		(L.L.Matrix_maxSpacing) (S.L.Matrix_SpacingMax)
		(L.L.Matrix_maxSpacing_u) (S.L.Matrix_SpacingMax_u)
		(L.$.Matrix_TerminusI1) (S.$.Matrix_TerminusString3)
		(L.$.Matrix_TerminusString3) $length 0 >
		{if}
			(L.$.Matrix_TerminusString3) (L.L.Font_0) (M.V.TextLength) 4 + (S.L.Matrix_Icon)
		{else}
			0 (S.L.Matrix_Icon)
		{endif}
		(L.L.Matrix_Width) (L.L.Matrix_Icon) - s9
		l9 (L.L.Matrix_LineWidth) - s0
		(L.L.Matrix_Heightvar0) !
		{if}
			0 (S.L.Matrix_Heightstring1) (S.L.Matrix_HeightvarL0)
		{else}
			(L.L.Matrix_HeightvarV) (S.L.Matrix_Heightstring1) (S.L.Matrix_HeightvarL0)
		{endif}
	{else}
		(L.$.Matrix_TerminusL3) (S.$.Matrix_TerminusString1)
		(L.$.Matrix_TerminusL4) (S.$.Matrix_TerminusString2)
		(L.L.Matrix_minSpacing) (S.L.Matrix_SpacingMin)
		(L.L.Matrix_maxSpacing_side) (S.L.Matrix_SpacingMax)
		(L.L.Matrix_maxSpacing_side_u) (S.L.Matrix_SpacingMax_u)
		(L.$.Matrix_TerminusI2) (S.$.Matrix_TerminusString3)
		(L.$.Matrix_TerminusString3) $length 0 >
		{if}
			(L.$.Matrix_TerminusString3) (L.L.Font_0_side) (M.V.TextLength) 4 + (S.L.Matrix_Iconside)
		{else}
			0 (S.L.Matrix_Iconside)
		{endif}
		(L.L.Matrix_Width) (L.L.Matrix_Iconside) - s9
		l9 (L.L.Matrix_LineWidth_side) - s0
		(L.L.Matrix_Heightvar1) !
		{if}
			0 (S.L.Matrix_Heightstring1) (S.L.Matrix_HeightvarL1)
		{else}
			(L.L.Matrix_HeightvarS) (S.L.Matrix_Heightstring1) (S.L.Matrix_HeightvarL1)
		{endif}
	{endif}
	
	(L.$.Matrix_TerminusString1) $length 0 >
	{if}
		(L.$.Matrix_TerminusString2) $length 0 = 
        {if} 
            (L.L.Matrix_Height) s1
        {else}
			(L.L.Matrix_HeightvarK) !
			{if}
				(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) + s1
			{else}
				(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) - s1
			{endif}
        {endif}

        (L.L.Matrix_SpacingMin) s2
        (L.L.Matrix_SpacingMax) s3		
		
		(L.L.CoD_MatrixIndex) 0 =
		(L.L.CoD_MatrixIndex) 1 = ||
		{if}
			(L.L.Matrix_InitStateFont) 1 =
			{if}
				(L.$.Matrix_TerminusString1) (M.L.Matrix_FittingFontInit)
				0 (S.L.Matrix_Xpos)
			{else}
				(L.$.Matrix_TerminusString1) (M.L.Matrix_FittingFont)
				l0 (L.L.Matrix_TextWidth) - 2 / l9 l0 - + (S.L.Matrix_Xpos)
			{endif}
		{endif}

		(L.$.Matrix_TerminusString2) $length 0 = 
		{if}
			l1 (L.L.Matrix_TextHeight) - 2 / (S.L.Matrix_Ypos)
        {else}
			0 (S.L.Matrix_Ypos)
        {endif}
		
		0
		(L.L.CoD_StartX) (L.L.Matrix_Xpos) +
		(L.L.CoD_StartY) (L.L.Matrix_Ypos) +
		(L.L.Matrix_FontIndex)
		2
		(L.L.Matrix_TextSpacing)
		(L.$.Matrix_TextToWrite)
		(M.V.STTextOut)
	{endif}

    (L.$.Matrix_TerminusString2) $length 0 >
    {if}
		(L.L.Matrix_HeightvarK) !
		{if}
			(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) - s1
		{else}
			(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) + s1
		{endif}
		
        (L.L.Matrix_SpacingMin) s2
        (L.L.Matrix_SpacingMax_u) s3
    
		(L.L.CoD_MatrixIndex) 0 =
		(L.L.CoD_MatrixIndex) 1 = ||
		{if}
			(L.L.Matrix_InitStateFont) 1 =
			{if}
				(L.$.Matrix_TerminusString2) (M.L.Matrix_FittingFontInit)
				0 (S.L.Matrix_Xpos)
			{else}
				(L.$.Matrix_TerminusString2) (M.L.Matrix_FittingFont)
				l0 (L.L.Matrix_TextWidth) - 2 / l9 l0 - + (S.L.Matrix_Xpos)
			{endif}
		{endif}

		(L.L.Matrix_HeightvarK) !
		{if}
			(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) + (S.L.Matrix_Ypos)
		{else}
			(L.L.Matrix_Height) 2 / (L.L.Matrix_Heightstring1) - (S.L.Matrix_Ypos)
		{endif}
		
		0
		(L.L.CoD_StartX) (L.L.Matrix_Xpos) +
		(L.L.CoD_StartY) (L.L.Matrix_Ypos) +
		(L.L.Matrix_FontIndex)
		2
		(L.L.Matrix_TextSpacing)
		(L.$.Matrix_TextToWrite)
		(M.V.STTextOut)
	{endif}
{end}

{macro:Matrix_Draw_Icon}
(M.L.Matrix_Data)

	(L.L.CoD_MatrixIndex) 0 =
	{if}
		(L.$.Matrix_TerminusI1) (S.$.Matrix_TerminusString4)
		(L.$.Matrix_TerminusString4) (L.L.Font_0) (M.V.TextLength) 2 + s9
		(L.L.Matrix_Width) l9 - s0
	{else}
		(L.$.Matrix_TerminusI2) (S.$.Matrix_TerminusString4)
		(L.$.Matrix_TerminusString4) (L.L.Font_0_side) (M.V.TextLength) 2 + s9
		(L.L.Matrix_Width) l9 - s0
	{endif}
	
	(L.$.Matrix_TerminusString4) $length 0 >
	{if}
		(L.L.Matrix_Height) s1
		
        1 s2
        1 s3		
		
		(L.L.CoD_MatrixIndex) 0 =
		(L.L.CoD_MatrixIndex) 1 = ||
		{if}
			(L.$.Matrix_TerminusString4) (M.L.Matrix_FittingFontLine)
			l0 (S.L.Matrix_Xpos)
		{endif}

		l1 (L.L.Matrix_TextHeight) - 2 / (S.L.Matrix_Ypos)
		
		0
		(L.L.CoD_StartX) (L.L.Matrix_Xpos) +
		(L.L.CoD_StartY) (L.L.Matrix_Ypos) +
		(L.L.Matrix_FontIndex)
		2
		(L.L.Matrix_TextSpacing)
		(L.$.Matrix_TextToWrite)
		(M.V.STTextOut)
	{endif}
{end}

{macro:Matrix_Draw_Rear}
(M.L.Matrix_Data)

	(L.L.Matrix_maxLinie_Rear) 1 + (L.L.Matrix_Xpos) - s0

	(L.$.Matrix_TerminusL5) $length 0 >
	{if}
		(L.$.Matrix_TerminusL6) $length 0 = 
        {if} 
            (L.L.Matrix_Height_side) s1
        {else}
            (L.L.Matrix_Height_side) 2 / s1
        {endif}
        1 s2
        1 s3		
		
		(L.L.Matrix_InitStateFont) 1 =
		{if}
			(L.$.Matrix_TerminusL5) (M.L.Matrix_FittingFontInit)
			0 (S.L.Matrix_Xpos)
		{else}
			(L.$.Matrix_TerminusL5) (M.L.Matrix_FittingFontRear)
			l0 (L.L.Matrix_TextWidth) - 2 / trunc (L.L.Matrix_maxLinie_Rear) 1 + l0 - + (S.L.Matrix_Xpos)
		{endif}

		(L.$.Matrix_TerminusL6) $length 0 = 
        {if}
            l1 (L.L.Matrix_TextHeight) - 2 / (S.L.Matrix_Ypos)
        {else}
			l1 11 >
			{if}
				l1 (L.L.Matrix_TextHeight) - 2 / (S.L.Matrix_Ypos)
			{else}
				0 (S.L.Matrix_Ypos)
			{endif}
        {endif}
		
		0
		0 (L.L.Matrix_Xpos) +
		56 (L.L.Matrix_Ypos) +
		(L.L.Matrix_FontIndex)
		2
		(L.L.Matrix_TextSpacing)
		(L.$.Matrix_TextToWrite)
		(M.V.STTextOut)
	{endif}

    (L.$.Matrix_TerminusL6) $length 0 >
    {if}
        (L.L.Matrix_Height_side) 2 / s1
        1 s2
        1 s3
    
		(L.L.Matrix_InitStateFont) 1 =
		{if}
			(L.$.Matrix_TerminusL6) (M.L.Matrix_FittingFontInit)
			0 (S.L.Matrix_Xpos)
			-1 (S.L.Matrix_InitStateFont)
		{else}
			(L.$.Matrix_TerminusL6) (M.L.Matrix_FittingFontRear)
			l0 (L.L.Matrix_TextWidth) - 2 / trunc (L.L.Matrix_maxLinie_Rear) 1 + l0 - + (S.L.Matrix_Xpos)
		{endif}

        l1 (L.L.Matrix_TextHeight) - 2 / l1 + (S.L.Matrix_Ypos)
        
		0
		0 (L.L.Matrix_Xpos) +
		56 (L.L.Matrix_Ypos) +
		(L.L.Matrix_FontIndex)
		2
		(L.L.Matrix_TextSpacing)
		(L.$.Matrix_TextToWrite)
		(M.V.STTextOut)
	{endif}
	0 (S.L.Matrix_Fontzent) (S.L.Matrix_Heightvar0) (S.L.Matrix_Heightvar1) (S.L.Matrix_Font)
	"" (S.$.Matrix_TerminusI1) (S.$.Matrix_TerminusI2)
{endif}
{end}

{macro:Matrix_Data}
(S.L.CoD_MatrixIndex)

0 (S.L.Matrix_Xpos) (S.L.Matrix_Ypos)

	(L.L.MatrixType) 0 =
	{if}
		1 (S.L.Matrix_Animation)
	{endif}
		
(L.L.CoD_MatrixIndex) 0 =
{if}
    0 (S.L.CoD_StartX)
    0 (S.L.CoD_StartY)
	
	(L.L.MatrixType) 0 =
	{if}
		216 (S.L.Matrix_Width)
		 26 (S.L.Matrix_Height)
		  4 (S.L.Matrix_HeightvarV)
	{endif}
	(L.L.Matrix_InitStateFont) 1 =
	{if}
		 1 (S.L.Matrix_MaxSpacing)
		 0 (S.L.Matrix_LineWidth) 
		76 (S.L.Matrix_Width)
		27 (S.L.Matrix_maxLinie)
		16 (S.L.Matrix_Height) (S.L.Matrix_Height_side)
	{endif}
{endif}

(L.L.CoD_MatrixIndex) 1 =
{if}
	0 (S.L.CoD_StartX)
	28 (S.L.CoD_StartY)
	
	(L.L.MatrixType)  0 =
	{if}
		140 (S.L.Matrix_Width)
		 19 (S.L.Matrix_Height) (S.L.Matrix_Height_side)
		  0 (S.L.Matrix_HeightvarS)
	{endif}
	(L.L.Matrix_InitStateFont) 1 =
	{if}
		 1 (S.L.Matrix_MaxSpacing)
		 0 (S.L.Matrix_LineWidth) 
		76 (S.L.Matrix_Width)
		27 (S.L.Matrix_maxLinie)
		16 (S.L.Matrix_Height) (S.L.Matrix_Height_side)
	{endif}
{endif}
(L.L.CoD_MatrixIndex) 2 =
{if}
	0 (S.L.CoD_StartX)
	56 (S.L.CoD_StartY)
{endif}

(L.L.Matrix_InitStateFont) 1 =
{if}
	 1 (S.L.Matrix_MaxSpacing)
	 0 (S.L.Matrix_LineWidth) 
	76 (S.L.Matrix_Width)
	27 (S.L.Matrix_maxLinie)
	16 (S.L.Matrix_Height)
{endif}
{end}

{macro:Matrix_FittingFont}
(S.$.Matrix_TextToWrite)
-1 (S.L.Matrix_FontIndex)

(L.L.CoD_MatrixIndex) 0 =
{if}
	(L.L.MatrixType) 0 =
	{if}
		(L.L.Matrix_Fontzent) 1 =
		{if}
			"DD-Mod System.F07" 7 (M.L.Matrix_FontDimensions)
			"DD-Mod B6H7S2.F08" 8 (M.L.Matrix_FontDimensions)
			"DD-Mod B9H11S3U.F13" 12 (M.L.Matrix_FontDimensions)
			"DD-Mod Helvetic.F17" 17 (M.L.Matrix_FontDimensions)
			"DD-Mod B12H22S3.F26" 26 (M.L.Matrix_FontDimensions)
			"DD-Mod B16H24S4.F24" 24 (M.L.Matrix_FontDimensions)
		{else}
			"DD-Mod System.F07" 7 (M.L.Matrix_FontDimensions)
			"DD-Mod B6H7S2.F08" 8 (M.L.Matrix_FontDimensions)
			"DD-Mod B9H11S3U.F13" 12 (M.L.Matrix_FontDimensions)
			"DD-Mod Helvetic.F17" 17 (M.L.Matrix_FontDimensions)
			"DD-Mod B12H22S3.F26" 23 (M.L.Matrix_FontDimensions)
			"DD-Mod B16H24S4.F24" 24 (M.L.Matrix_FontDimensions)
		{endif}
	{endif}
{endif}

(L.L.CoD_MatrixIndex) 1 =
{if}
	(L.L.MatrixType) 0 =
	{if}
		(L.L.Matrix_Fontzent) 1 =
		{if}
			"DD-Mod System.F07" 7 (M.L.Matrix_FontDimensions)
			"DD-Mod B6H7S2.F08" 8 (M.L.Matrix_FontDimensions)
			"DD-Mod Helvetic.F17" 17 (M.L.Matrix_FontDimensions)
			"DD-Mod B10H17S3.F19" 19 (M.L.Matrix_FontDimensions)
		{else}	
			"DD-Mod System.F07" 7 (M.L.Matrix_FontDimensions)
			"DD-Mod B6H7S2.F08" 8 (M.L.Matrix_FontDimensions)
			"DD-Mod Helvetic.F17" 19 (M.L.Matrix_FontDimensions)
			"DD-Mod B10H17S3.F19" 17 (M.L.Matrix_FontDimensions)
		{endif}
	{endif}
{endif}
{end}

{macro:Matrix_FittingFontLine}
(S.$.Matrix_TextToWrite)
-1 (S.L.Matrix_FontIndex)

(L.L.CoD_MatrixIndex) 0 =
{if}
	(L.L.MatrixType)  0 =
	{if}
		"DD-Mod TB26L" 26 (M.L.Matrix_FontDimensions)
	{endif}
{endif}

(L.L.CoD_MatrixIndex) 1 =
{if}
	(L.L.MatrixType) 0 =
	{if}
		"DD-Mod SLSmall.F19" 16 (M.L.Matrix_FontDimensions)
	{endif}
{endif}
{end}

{macro:Matrix_FittingFontRear}
(S.$.Matrix_TextToWrite)
-1 (S.L.Matrix_FontIndex)

	(L.L.MatrixType) 0 =
	{if}
		"DD-Mod System.F07" 7 (M.L.Matrix_FontDimensions)
		"DD-Mod B6H7S2.F08" 8 (M.L.Matrix_FontDimensions)
		"DD-Mod B10H17S3.F19" 17 (M.L.Matrix_FontDimensions)
		"DD-Mod SLSmall.F19" 16 (M.L.Matrix_FontDimensions)
	{endif}
{end}

{macro:Matrix_FittingFontInit}
(S.$.Matrix_TextToWrite)
-1 (S.L.Matrix_FontIndex)

	(L.L.MatrixType) 0 =
	{if}
		"DD-Mod System.F07"  7 (M.L.Matrix_FontDimensions)
	{endif} 
{end}

{macro:Matrix_FontDimensions}
s6 l1 <=
{if}
	(M.V.GetFontIndex) s4 (L.$.Matrix_TextToWrite) (M.V.TextLength) s5
	l5 (L.$.Matrix_TextToWrite) $length 1 - l2 * + l0 <=
	(L.L.Matrix_FontIndex) -1 = ||
	{if}
		l0 l5 - (L.$.Matrix_TextToWrite) $length 1 - / trunc l2 max l3 min (S.L.Matrix_TextSpacing)
		l5 (L.$.Matrix_TextToWrite) $length 1 - (L.L.Matrix_TextSpacing) * + (S.L.Matrix_TextWidth)
		l6 (S.L.Matrix_TextHeight)
		l4 (S.L.Matrix_FontIndex)
	{endif}
{endif}
{end}

{macro:matrix_refreshIntIndex}
	(L.L.matrix_steckschild_Termindex) s0 0 >=
	l0 0 (M.V.GetTerminusString) "" $= ! &&
	{if}
		l0
	{else}
		(L.L.Matrix_TerminusAct)
	{endif}
	(S.L.target_index_int)
{end}

{macro:Matrix_DrawingOn}
	(L.L.Matrix_IsDrawing) !
	{if}
		1 (M.V.STLock)
		1 (M.V.STLock)
		1 (S.L.Matrix_IsDrawing)
	{endif}
{end}

{macro:Matrix_DrawingOff}
	(L.L.Matrix_IsDrawing)
	{if}
		1 (M.V.STUnlock)
		1 (M.V.STFilter)
		0 (S.L.Matrix_IsDrawing)
	{endif}
{end}

'Matrix_CapitalizeString-Makro entnommen aus dem Krüger++ Script
{macro:Matrix_CapitalizeString}
"" (S.$.Matrix_CapStr) $+
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep) (M.L.Matrix_CapitalizeStringStep)
(L.$.Matrix_CapStr)
{end}

{macro:Matrix_CapitalizeStringStep}
$d $length 1 >
{if}
    $d 1 $SetLengthR $d 1 $SetLengthL
    $d " " $= $d "-" $= || $d "<" $= || $d "(" $= || $d "+" $= || "/" $= || !
    1 $SetLengthR &&
    {if}
        (M.L.Matrix_CharToLowerCase)
    {endif}
    (L.$.Matrix_CapStr) $+ (S.$.Matrix_CapStr) 0 $* $+
    1 $cutEnd
{endif}
$d $length 1 =
{if}
  (L.$.Matrix_CapStr) $+ (S.$.Matrix_CapStr) ""
  1 $cutEnd
{endif}
{end}

{macro:Matrix_CharToLowerCase}
0
d ! $d "q" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
d ! $d "p" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
d ! $d "g" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
d ! $d "j" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
d ! $d "y" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
d ! $d "ß" $= && {if} 1 (S.L.Matrix_Fontzent) {endif}
{end}
