Gli operatori di confronto utilizzati con 2 testi
Il codice
1 2 3 4 5 6 7 8 9 10 |
TextWindow.Write("Primo testo: ") testo1 = TextWindow.Read() TextWindow.Write("Secondo testo: ") testo2 = TextWindow.Read() If(testo1 = testo2) Then TextWindow.WriteLine(testo1 + " = " + testo2) Endif If(testo1 <> testo2) Then TextWindow.WriteLine(testo1 + " <> " + testo2) Endif |
Se le due condizioni sono esclusive è il caso di utilizzare la selezione doppia
1 2 3 4 5 6 7 8 9 |
TextWindow.Write("Primo testo: ") testo1 = TextWindow.Read() TextWindow.Write("Secondo testo: ") testo2 = TextWindow.Read() If(testo1 = testo2) Then TextWindow.WriteLine(testo1 + " = " + testo2) Else TextWindow.WriteLine(testo1 + " <> " + testo2) Endif |
Si può stabilire se 2 testi sono uguali oppure diversi
- il confronto è case sensitive
- non sa fare il confronto lessicografico: <, <=, >, >=.