function Boolean2String (Status,Form,Klammer) { // Stand: 18.08.2020 // Konvertierung Boolean in String. // Gibt für true/false oder 1/0 diverse Texte zurück. Optional mit Klammern. // undefined erscheint als'u'. // Unbekannte Eingangswerte geben '?' zurück. // GLOBALE DEBUG-AUSGABEN GEHEN NICHT!?! var Text; // Rückgabewert var Space; // Leerzeichen falls gewünscht switch (Form) { case 'E/A': if ( Status == true || Status == 1 ) { Text='E' }; if ( Status == false || Status == 0 ) { Text='A' }; break; case 'ein/aus': if ( Status == true || Status == 1 ) { Text='ein' }; if ( Status == false || Status == 0 ) { Text='aus' }; break; case 'an/aus': if ( Status == true || Status == 1 ) { Text=' an' }; if ( Status == false || Status == 0 ) { Text='aus' }; break; case 'j/n': if ( Status == true || Status == 1 ) { Text='j' }; if ( Status == false || Status == 0 ) { Text='n' }; break; case 'J/N': if ( Status == true || Status == 1 ) { Text='J' }; if ( Status == false || Status == 0 ) { Text='N' }; break; case 'ja/nein': if ( Status == true || Status == 1 ) { Text=' ja ' }; if ( Status == false || Status == 0 ) { Text='nein' }; break; default: console.debug('### Boolean2String-Fehler Status="'+Status+'" Form="'+Form+'" Klammer="'+Klammer+'"'); Text = '?'; break; } // undefined Kennzeichnen if ( Status == undefined ) { Text='u' }; // Positive Werte setzen die Klammern mit Space, negative ohne Space. if ( Klammer > 0 ) { Space=' ' } else { Space='' }; // Nur Ganzzahlige Werte Klammer=Math.abs( Klammer ); switch (Klammer) { case 1: Text = '('+Space+Text+Space+')'; break; case 2: Text = '['+Space+Text+Space+']'; break; case 3: Text = '{'+Space+Text+Space+'}'; break; case 4: Text = '<'+Space+Text+Space+'>'; break; case 5: Text = '>'+Space+Text+Space+'<'; break; default: console.debug('### Boolean2String-Fehler Status="'+Status+'" Form="'+Form+'" Klammer="'+Klammer+'"'); Text = '?'; break; } return Text; } ###################################################################### function Fstr (Str,L,A) { // Stand: 18.08.2020 // Formatiert einen String auf Länage und Ausrichtung. // Ist der String länger als die Wunschlänge oder die Ausrichtung unbekannt wird ein '?' zurückgegeben. // GLOBALE DEBUG-AUSGABEN GEHEN NICHT!?! var Space = ' '; // Leerzeichen zum Auffüllen var L2; // Hilfsvariable für die Länge Str = String(Str); // Als String verarbeiten! if ( Str.length <= L ) { switch (A) { case 1: // rechts Str = Space+Str; Str = Str.substring(Str.length - L); break; case 2: // links Str = Str+Space; Str = Str.substring(0, L); break; case 3: // mitte L2 = Math.round( (L - Str.length)/2-0.5); Str = Space.substring(0,L2)+Str+Space.substring(0,L2); Str = Space+Str; Str = Str.substring(Str.length - L); break; default: console.debug('#### FSTR-Fehler Str="'+Str+'" A="'+A+'"'); Str = '?'; break; } } else { console.debug('#### FSTR-Fehler Str="'+Str+'" A="'+A+'" String zu lang'); Str = '?'; } return Str; }