Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualdtkaos

Posted 24 June 2013 - 05:33 PM

Doesn't beat my wonderful "String to Char" function I designed back in 2008. A masterpiece. With original comments!

 

function StrToChr(S: String): Char;  // Fonction pour transformer un String en Char
begin                                // Je n'en disposait pas de préfaite... si vous connaissez un
     if UpperCase(S) = 'A' then Result := 'A';    // moyen plus rapide, faites le moi savoir :)
     if UpperCase(S) = 'B' then Result := 'B';
     if UpperCase(S) = 'C' then Result := 'C';
     if UpperCase(S) = 'D' then Result := 'D';
     if UpperCase(S) = 'E' then Result := 'E';
     if UpperCase(S) = 'F' then Result := 'F';
     if UpperCase(S) = 'G' then Result := 'G';
     if UpperCase(S) = 'H' then Result := 'H';
     if UpperCase(S) = 'I' then Result := 'I';
     if UpperCase(S) = 'J' then Result := 'J';
     if UpperCase(S) = 'K' then Result := 'K';
     if UpperCase(S) = 'L' then Result := 'L';
     if UpperCase(S) = 'M' then Result := 'M';
     if UpperCase(S) = 'N' then Result := 'N';
     if UpperCase(S) = 'O' then Result := 'O';
     if UpperCase(S) = 'P' then Result := 'P';
     if UpperCase(S) = 'Q' then Result := 'Q';
     if UpperCase(S) = 'R' then Result := 'R';
     if UpperCase(S) = 'S' then Result := 'S';
     if UpperCase(S) = 'T' then Result := 'T';
     if UpperCase(S) = 'U' then Result := 'U';
     if UpperCase(S) = 'V' then Result := 'V';
     if UpperCase(S) = 'W' then Result := 'W';
     if UpperCase(S) = 'X' then Result := 'X';
     if UpperCase(S) = 'Y' then Result := 'Y';
     if UpperCase(S) = 'Z' then Result := 'Z';
end;

Actually I enumerated the alphabet at least three times in the code (hangman game, if you must know).

 

At least this is self-documenting, in a redundant kind of way ph34r.png

 

 

That's awesome! I use java and the first thing in my mind is a string to lowercase(or uppercase) then thake that string to to char array would solved have that problem.

 

My very first code was c# to back in 2004? I was like 14 and I only messed around with c# for 2 weeks but it was  a series of dialogbox not in a loop. I literally copy and pasted that many lines of code and I tought it was haularious to have people click the first one thinking it would go away.


#1dtkaos

Posted 24 June 2013 - 05:33 PM

Doesn't beat my wonderful "String to Char" function I designed back in 2008. A masterpiece. With original comments!

 

function StrToChr(S: String): Char;  // Fonction pour transformer un String en Char
begin                                // Je n'en disposait pas de préfaite... si vous connaissez un
     if UpperCase(S) = 'A' then Result := 'A';    // moyen plus rapide, faites le moi savoir :)
     if UpperCase(S) = 'B' then Result := 'B';
     if UpperCase(S) = 'C' then Result := 'C';
     if UpperCase(S) = 'D' then Result := 'D';
     if UpperCase(S) = 'E' then Result := 'E';
     if UpperCase(S) = 'F' then Result := 'F';
     if UpperCase(S) = 'G' then Result := 'G';
     if UpperCase(S) = 'H' then Result := 'H';
     if UpperCase(S) = 'I' then Result := 'I';
     if UpperCase(S) = 'J' then Result := 'J';
     if UpperCase(S) = 'K' then Result := 'K';
     if UpperCase(S) = 'L' then Result := 'L';
     if UpperCase(S) = 'M' then Result := 'M';
     if UpperCase(S) = 'N' then Result := 'N';
     if UpperCase(S) = 'O' then Result := 'O';
     if UpperCase(S) = 'P' then Result := 'P';
     if UpperCase(S) = 'Q' then Result := 'Q';
     if UpperCase(S) = 'R' then Result := 'R';
     if UpperCase(S) = 'S' then Result := 'S';
     if UpperCase(S) = 'T' then Result := 'T';
     if UpperCase(S) = 'U' then Result := 'U';
     if UpperCase(S) = 'V' then Result := 'V';
     if UpperCase(S) = 'W' then Result := 'W';
     if UpperCase(S) = 'X' then Result := 'X';
     if UpperCase(S) = 'Y' then Result := 'Y';
     if UpperCase(S) = 'Z' then Result := 'Z';
end;

Actually I enumerated the alphabet at least three times in the code (hangman game, if you must know).

 

At least this is self-documenting, in a redundant kind of way ph34r.png

 

 

That's awesome! I use java and first thing in my mind is a string to lowercase(or uppercase) then thake that string to to char array would solved have that problem.

 

My very first code was c# to back in 2004? I was like 14 and I only messed around with c# for 2 weeks but it was  a series of dialogbox not in a loop. I literally copy and pasted that many lines of code and I tought it was haularious to have people click the first one thinking it would go away.


PARTNERS