xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_DecodeOrEmpty()

Provides a functional equivalent for the DO CASE statement.

Syntax

HB_DecodeOrEmpty( <xInitVal>        , ;
                  <xCase1>, <xRet1> , ;
                 [<xCaseN>, <xRetN>], ;
                 [<xDefault>]         ) --> xReturn

or

HB_DecodeOrEmpty( <xInitVal>, ;
                  <hHash>   , ;
                 [<xDefault>] ) --> xReturn

Arguments

<xInitVal>
This is an arbitrary value being tested against <xCase1> to <xCaseN> or the keys of <hHash>.
<xCase>, <xRet>
The parameters <xCase> and <xRet> must be specified in pairs. <xCase> is the value compared with <xInitVal>. When both are the same, the return value is <xRet>
<xDefault>
This is an optional default value being returned when no match is found. It defaults to an empty value having the same data type as <xInitVal>.
<hHash>
Instead of passing pairs of <xCase> and <xRet> parameters, a single Hash() can be passed holding key/value pairs. <xCase> is compared with the hash keys. When a match is found, the hash value is returned.

Return

The function works exactly the same as HB_Decode(): it returns the value <xRet> when <xInitValue> matches <xCase>. If no match is found <xDefault>, if specified, is returned. The difference to HB_Decode() is the default return value when no match is found and <xDefault> is not specified: the function returns an empty value of the same data type as <xInitVal> as default.

Info

See also:HB_Decode()
Category: Conversion functions , xHarbour extensions
Source:rtl\decode.prg
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe