2024-02-09 15:08:56 |
Dirk Zimoch |
description |
A template file that only contains macros with default values can be loaded with `dbLoadRecords("file.db","")` but not with `dbLoadRecords("file.db",NULL)`. In particular, in the startup script, it cannot be loaded with `dbLoadRecords "file.db"` but only with `dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)
Using such a macro in a record name results in the error message:
ERROR: Bad character '$' in Record/Alias name "$(P=)Name"
Using macros with defaults in fields shows error messages like this:
ERRORName.PREC Has unexpanded macro
Can't set "Name.PREC" to "$(PREC=3)" : Bad Field value
ERRORERROR failed to load 'file.db'
(Unrelated: Someone please fix the missing blanks after ERROR and the ERRORERROR.)
The reason is that `dbReadCOM`, the function that does the real work, only creates a `macHandle` when `substitutions` is not `NULL`. Not having a `macHandle` prevents any macro substitution from working, even those which provide a default value.
In the old times, when macros could not have defaults, this was fine, but not any more. A macro handle should always be created, even it it stays empty when `substitutions` is `NULL`. |
A template file that only contains macros with default values can be loaded with `dbLoadRecords("file.db","")` but not with `dbLoadRecords("file.db",NULL)`. In particular, in the startup script, it cannot be loaded with `dbLoadRecords "file.db"` but only with `dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)
Using such a macro in a record name results in the error message:
ERROR: Bad character '$' in Record/Alias name "$(P=)Name"
Using macros with defaults in fields shows error messages like this:
ERRORName.PREC Has unexpanded macro
Can't set "Name.PREC" to "$(PREC=3)" : Bad Field value
ERRORERROR failed to load 'file.db'
(Unrelated: Someone please fix the missing blanks after ERROR and the ERRORERROR.)
The reason is that `dbReadCOM`, the function that does the real work, only creates a `macHandle` when `substitutions` is not `NULL`. Not having a `macHandle` prevents any macro substitution from working, even those which provide a default value.
In the old times, when macros could not have defaults, this was fine, but not any more. A macro handle should always be created, even if it stays empty when `substitutions` is `NULL`. |
|