Subj : Translating CASE from BAS
To   : Mike Luther
From : Herbert Bushong
Date : Wed Feb 07 2001 09:54 pm

Mike,

::>      2.) SWITCH functions only with numeric logic, as I now think
::>          is the only way it works.  That's what I learned in the
::>          Watcom Forum when this question was posed there.

::> That works fine for numeric-based stuff.  In my limited knowledge of C++,
::> can degenerate into lots and lots of lines of code for non-numeric logic.

Yes, it's difficult. But look at it from a different angle: All char's have a
numeric equivalent, and you don't have to use that numeric equivalent to check
for chars in a switch:

char num[2];
// get a number/char whatever in num[]

switch (*num)
{
 case '0':
 .
 case '9':
 case 'a':
 case 'A':
 case 'b':
 case 'B':
 .
 .
 default:
};

That's the same as using a select case ASC("*")  in basic *=some character.
That doesn't help with full strings, but it may give you ideas. And it's a
generic solution.

::> still seems to me that handling strings ain't near so easy in C++ as it is
::> BASIC, sigh..

That is true, strings are much easier in Basic.

::> I think Sarah is faced with this same problem as well, but maybe not in WA
::> V11, but some other compiler.  Thus the problem is generic?  But is sure i
::> OS/2 programming related, at least to me and I suspect others.

I've been discussing Sarah's problem with her via e-mail, and the solution was
similar to the above.





---


--- QScan/PCB v1.20a / 02-1026