On May 31, 2007, at 8:14 AM, joe at strout dot net wrote:
> On May 31, 2007, at 15:09 UTC, Terry Ford wrote:
>
>> Would there be any support for a built-in Rb complement to CStr when
>> converting "True" as a string to the Boolean value of True?
>>
>> Something like a "BVal" function?
>
> That'd be the complement of CDbl, not CStr. You can already do
> this by
> passing it through a Variant. And making your own (as you noted) is
> very trivial too. I personally don't see the need to add another
> global function to the framework for this rarely-needed operation.
I actually have my own function for this that handles either the text
or numeric values for true used in other environments:
Function GetBoolVal(value As Variant) As Boolean
If value.Type = Variant.TypeInteger Then
If value = 1 Then
Return True
Else
// anything not 1 is false in our world
Return False
End If
ElseIf value.Type = Variant.TypeString Then
If value = "true" or value = "1" Then
Return True
Else
// anything not "true" or "1" is false in our world
Return False
End If
ElseIf value.Type = Variant.TypeBoolean Then
Return value
End If
// Just for safety sake
Return False
End Function
It works great for the work I do calling external shell tools where I
deal with returns of both the words and the values.
Tim
--
Tim Jones
tjmac at tolisgroup dot com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|