Solved

Translating Fortran To Create A Static Display Box

Posted on 1998-12-21
12
306 Views
Last Modified: 2013-11-08
Below is part of the code in Fortran which produces a static display box with numeric information.

I need to make this box function as it does now except on a different system (Windows NT) and with C++.  The function calls below seem to draw the box, lines and text at specific
positions on the screen.  If C++ provides no facilities for doing this directly, how can I ensure the box is displayed at the top of the screen.
   
This box will be displayed from a true windows program,
rather than a console program.  Where do I begin???  Thanks!

IF (PAINT_B) THEN                                  ! Do paint the status box

          CALL             DBL_TEXT (               ! Display double sized text with
     1      'OMS Production Management',              !  text,
     2      1,                                              !  row,
     3      18,                                             !  column,
     4      ATRIB_B)                                        !  attributes defined

          CALL             ERASE_AREA (               ! Erase screen area with
     1      9,                                              !  the begining row,
     2      1,                                              !  the begining column,
     3      2,                                              !  the number of rows to erase,
     4      80)                                            !  the number of columns to erase.

          CALL             DRAW_A_BOX (               ! Draw a box with
     1      3,                                              !  top row,
     2      1,                                              !  left column,
     3      10,                                             !  bottom row,
     4      80,                                             !  right column,
     5      ATRIB_B)                                        !  display attribute.

          CALL             DRAW_HLINE (               ! Draw a horizontal line with
     1      7,                                              !  row,
     2      1,                                              !  left column,
     3      80,                                             !  right column,
     4      ATRIB_B)                                        !  attributes defined

          CALL             DRAW_VLINE (               ! Draw a vertical line with
     1      3,                                              !  top row,
     2      20,                                             !  column,
     3      7,                                              !  bottom row,
     4      ATRIB_B)                                        !  attributes defined

          CALL             DRAW_VLINE (               ! Draw a vertical line with
     1      3,                                              !  top row,
     2      45,                                            !  column,
     3      7,                                              !  bottom row,
     4      ATRIB_B)                                        !  attributes defined

          CALL             DRAW_VLINE (              ! Draw a vertical line with
     1      3,                                              !  top row,
     2      67,                                            !  column,
     3      7,                                              !  bottom row,
     4      ATRIB_B)                                        !  attributes defined

          IF (DSP_SLT.EQ.DISABLE) THEN          ! Enable backlog display

            PAINTBL = .TRUE.                         ! Set paint backlog flag
            PAINTJS = .FALSE.                         ! Set paint job slot flag

          ELSE                                              ! Disable backlog display

            PAINTBL = .FALSE.                         ! Set paint backlog flag
            PAINTJS = .TRUE.                          ! Set paint job slot flag

          ENDIF                                             ! Backlog display

          PAINT_B = .FALSE.                           ! Clear paint box flag

          PAINT_N = .TRUE.                            ! Set paint network status flag
          PAINT_T = .TRUE.                            ! Set paint station status flag
          PAINT_W = .TRUE.                            ! Set paint center status flag

        ENDIF                                               ! Paint the status box

        RETURN

        END
0
Comment
Question by:John500
12 Comments
 

Author Comment

by:John500
ID: 1180730
Edited text of question
0
 
LVL 11

Expert Comment

by:alexo
ID: 1180731
Try the MessageBox() function.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1180732
I was going to return your last e-mail, when I saw this.

Since you are changing from a DOS based program to a true windows program--not a console program.  You are going to find that code like this--basicaly any code that deals with the user interface will change so radically that there is no "translation".  

You've got boxes that display text in them.  Those will likely become windows of some sort, like static text windows.  (In windows programming we use the term "windows" differently than the end user.  To the end user only a window that can be moved with a mouse, is a "window".  To a programmer, though one of those movable windows can have non-movable windows on top of it.  The boxes, where you enter text or the buttons you press are all windows as well.  The text will probably be displayed in one of these little windows, one with a border.)

However, the code to create and manage these windows is so entirely different that there is no comparison to the old code.  Does the programmer writting this know anything about windows programming?  
0
 

Author Comment

by:John500
ID: 1180733
Todd,

As a junior programmer, I'm not sure who will end up with the sole responsibility of making sure this code works, but for the time being I have been tasked to find out what it entails and if I can do it.

I would like to report that I am able to do the job over the next month.  As for my programming knowledge, you know what my skill level is or isn't.

0
 

Expert Comment

by:McCreary
ID: 1180734
The code you list is not Fortran.  It is a Fortran program calling some screen management functions, somebodys GUI library.  I think that it would be neither effecient nor effective to "translate" this user interface portrion of your program.  It would take less time to rebuild it from scratch.

My experience is that translating the Fortran calculation routines to C is just a matter of using a string editor to change the grammar.  "DO" becomes "for" and so forth.  Notice that this gives you a translation to C since Fortran is not object oriented.  To convert to C++ taking advantange of classes and so forth takes are re-design.  But, if you just want it to run you don't have to have classes, C is a sub-set of C++.

It is also possible to static link to Fortran routines from C++ so you don't have to even translate the Fortran calculation for use with a MFC Windows User Interface.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1180735
As I said before, the easiest thing to do is to make this a win32 console program.  Because for a console program, the whole user interface concept remains the same.  i.e you output text on the screen and it overwrites what was there and it stays there, i.e. once it is outputted to the screen it remains there until it is overwritten and you don't need to"maintain" it.  
'
With a true windows program.  None of that is true.  There is no console.  So first of all your program must create 1 or more "main windows" for the user to work with.  In additon to putting in code that creates, these windows, it must have code that manages them.  Each time the window is repainted (redisplayed), moved, clicked on with a mouse etc, code must be executed to make the window respond.  The the program probalby creates more windows on top of these windows.  These are the windows that will have the messages etc, maybe buttons and menus and so on.  

In additon the way the program is structured at heart will change.  The DOS program, was probably "modal" it had many different-seperate input modes.  It may start of with a manu where the program is looping around waiting for a valid key form the user.  When it gets one, say "O" for "open file" it then changes mode and executes a new procedure that tries to get a file name from tne user.  Then it opens the file, uses it, and returns back to the menu and the menu mode.   That whole sort of design makes no sense in windows.  It is totally lost

In windows, a program does its intialization and ussually opens up a main window or two and then it executes a message loop.  This is a loop that executes for the rest of the duration of the program.  When the program is done, the loop ends and the the program returns.  When things "need to be done" messages are sent from the message loop to the windows that need to do things, these window then call code to handle the task.  thus if if a file needs to be opened, the user may select an "open" command from the menu.  (This whole task involves a flurry of messages)  Eventually the window will receive a message that says the the user chose the open command.  Then you have code that detects this and handles it.  Most liklely it will display a dialog box asking the user to enter the file name.  etc.  As you can see this  is conceptually  a very different design.  There is almost no opportunity for code reuse of the user interface code   So the sort of stuff you,ve asked about is probably irrelevant.  It will not get converted.  

I think you or the programmer who will be working on this needs to get some windows programming books.  I would start with Teach Yourself Windows Programming in 21 days.  Forget the old program, just get an idea of what windows programs are like.  Then write a few easy windows programs (the book will have lots of examples and starter programs.)  Then worry about how to convert the old program.

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Expert Comment

by:yoffe
ID: 1180736
Nietod is right.   When I first started writing windows programs, I was approached by the U.S. forest service and to do a "direct translation" of 10 yr old apple basic to VC++ 1.52.   Didnt happen.   Instead, their 132 column list printout found its way to the trash and I requested screen shots of the old program just to give me an idea what they wanted.

BTW, this is just an opinion, and many will probably disagree, but I think its important to understand the foundation of SDK (Software development kit - straight C), before floundering into MFC (Microsoft's class library).   If you dont really understand what if going on at the low levels, strange program behavior at the MFC level can't be effectively troubleshooted (or is it troubleshot).   Nietod's suggestion (Windows Prog in 21 days), is a good book to gain that base understanding of windows programming (I own Version 1.0, so I could be wrong).   Just my opinion.   Good Luck!
0
 
LVL 2

Expert Comment

by:Slarti
ID: 1180737
I agree with everything so far except the book reocmmendation. Unlike nietod, I do suggest diving straight into MFC, _provided_ that the programmer (whoever that may tunr out to be) is proficient in C++. While an understanding of the Windows system is important for advanced programming, beginners will have a much sharper learning curve if they can start creating apps with AppWizard and skip all the mess with the message processing routines. My recommendation is Kruglinski's "Inside Visual C++". However, you really need to know C++ (not just C) in order to make heads or tails of MFC.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1180738
Agreed to some extent.  But one major problem with MFC is that it is really aimed at generating document based applications (MDI and SDI).  You can generate programs with a less document oriented approach, but you need to know what you are doing.  DOS legacy apps (and others) often don't lend themselves to a document oriented approach.  Thus a novice may have a hard time with MFC on those projects.
0
 

Author Comment

by:John500
ID: 1180739
Todd,

Can you think of any issues which require VC to be used instead of VB for any project?  Is it strictly a development preference or are there other things to consider.

For this display box, wouldn't it be easier to use VB instead of VC since VB makes development less complicated?

Our project entails migrating from a VAX system to Windows NT. Our new database will be on SQL Server which requires the new Windows interface.  We are using PathWorks to facilitate the dump of info from one system to the other.  With all this in mind, again I ask if it matters which development software we use?  Thanks!
0
 
LVL 22

Expert Comment

by:nietod
ID: 1180740
There are some cases where VB can't be used, but I doubt any apply.  For example, if your projec is for a "plug-in" that gets plugged into an application someone else wrote (to enhance or customize the application), VB probably can't be used as plug ins are ussually DLLs and VB can't create DLLs.  Another reason might be that you were entending to speed up development using libraries that were written for C++, that sort of thing.  But for a completely self-contained app that does not use external libraries, there is probably no reason you would have to use VC.

However, I don't think that development is necessarily less complicated in VC or VB.  (Well, for simple cases and for beginers VB probably is easier..)  Many of the issues you have to condend with are due to the nature of changing from a modal, text-based console application to a modeless, event-driven, GUI application.  These requires a lot of redesigning no mater what language you use.
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1180741
I'm answering as requested in an e-mail.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now