Does anyone know how to determine if a variable that is passed in as an argument in a procedure is a binary string? The [string is .. ] command does not seem to cover this data type.
It doesn't look like 'binary scan' will do the trick, as the
following example shows that binary scan will return 1
whether the variable is a binary string or a list of integers.
% binary scan [binary format c* {0 1 2}] c* a
1
% set a
0 1 2
% binary scan {0 1 2} c* a
1
% set a
48 32 49 32 50
But you've given me an idea. All I really want to do is
differentiate between a binary string and a list of integers,
so I can catch the return on format %d:
% format %d [lindex {0 1 2} 0]
0
%format %d [lindex [binary format c* {0 1 2}] 0]
expected integer but got "??"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.