Subj : Translating CASE from BASIC to C++
To : All
From : Mike Luther
Date : Wed Feb 07 2001 01:17 am
I've been faced with the job of translating everything from PowerBASIC to C++
in order to survive. Like it or not I have to provide application
cross-platform compatibility between DOS, OS/2 and .. WIN-xx, if I go into
that. I've also been advised by one client that the Feds told them that here
in the USA, 7 years of support have to be given for any old system when a new
one is implemented in certain medical applications with medical records. I
don't represent that as gospel, only what I have been told to expect... ;)
Now .. the only way I can seemingly, perhaps, gain seven years of
cross-platform interoperability between OS/2, and DOS ... and shudder,WIN-xx ..
is with WATCOM V11(b) which I licensed along with the books, and where it may
go as version (c) etc., a long time ago.
So ..
I'm about 60% through writing an auto-translator from PowerBASIC 3.5 source to
Watcom V11 (b). It's been educational. One of the things that has been a
stumbling block to me is the use of CASE in BASIC where the switch logic is
based not on numeric conditionals, but alpha conditionals.
This surfaced in the OS/2 echo a bit ago with something that Sarah replied to.
I posted it in the Watcom Forum. I'd like to attempt to re-look at the issue
here to see if anyting inspirational shows here please:
1.) How can you handle CASE translations from BASIC to C++
for OS/2, with emphasis on WATCOM V11(b) as the toolset?
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.
3.) Based on what I learned from the Watcom Forum, my intitial
translator algorithim was writtne to simply back-level
all SELECT CASE in BASIC to the crude IF / THEN logic.
Write the translator so that it converts the SELECT CASE
to form a conditional master variable, based on what
was used for the SELECT conditional variable.
Re-design SELECT CASE as a parade of IF/THEN constructs.
That works fine for numeric-based stuff. In my limited knowledge of C++, it
can degenerate into lots and lots of lines of code for non-numeric logic. It
still seems to me that handling strings ain't near so easy in C++ as it is in
BASIC, sigh..
Using the stock WATCOM libraries, remember this has to work across, DOS,OS/2
and .. shudder .. likely WIN-xx too, what do we do? Suggestions would be
appreciated. However, that's really unfair, isn't it? ;)
I think Sarah is faced with this same problem as well, but maybe not in WATCOM
V11, but some other compiler. Thus the problem is generic? But is sure is
OS/2 programming related, at least to me and I suspect others.
Thanks ..
Mike @ 117/3001
--- Maximus/2 3.01
* Origin: Ziplog Public Port (1:117/3001)