Blitz_Basic_Bool.bb
| Name: | Blitz_Basic_Bool.bb |
| Version: | 1.0 |
| Released: | September 10th, 2006 |
| Description: | Converts a string to a boolean value and vice-versa. |
| Direct Download: | Download Now (1.27KB) |
; ---------------------------------------------------------------------- ; -- Blitz_Basic_Bool.bb ; -- ; -- Converts a string to a boolean value (true or false) ; -- ; -- Version : 1.0 ; -- Licence : Public Domain ; ---------------------------------------------------------------------- ;;; <summary>Converts a string to a boolean value.</summary> ;;; <param name="boolString">The string to convert.</param> ;;; <param name="defaultValue ">The default value to return if the string is not valid.</param> ;;; <returns>True or False.</returns> ;;; <subsystem>Blitz.Basic</subsystem> Function Bool(boolString$, defaultValue = False) Local boolValue = defaultValue Select Lower(boolString$) Case "true" : boolValue = True Case "false": boolValue = False Case "1" : boolValue = True Case "0" : boolValue = False End Select Return boolValue End Function ;;; <summary>Converts an integer value to its textual boolean value.</summary> ;;; <param name="boolValue">The value to convert.</param> ;;; <returns>The string "True" if boolValue is greater than 0, else returns "False".</returns> ;;; <subsystem>Blitz.Basic</subsystem> Function BoolStr$(boolValue%) If boolValue > 0 Then Return "True" Else Return "False" EndIf End Function