Description: |
call:lookup key map ret |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.
|
:lookup key map ret -- returns the value associated with a key in a map of key-value pairs
:: -- key [in] - key to lookup
:: -- map [in] - map with key-value pairs, i.e. key1-val1;key2-val2;key3-val3
:: -- ret [out] - valref for return value
:$created 20060101 :$changed 20080219 :$categories Lookup
:$source https://www.dostips.com
SETLOCAL
SET map=%~2
CALL SET ret=%%map:*%~1-=%%
SET ret=%ret:;=&:%
IF "%ret%" NEQ "%ret:-=%" set ret=
( ENDLOCAL & REM RETURN VALUES
IF "%~3" NEQ "" (SET %~3=%ret%) ELSE ECHO.%ret%
)
EXIT /b
|
|