Graph unit.....

I recently was given a task to fix problems and enhance the features of
a small utility program. By using the 'MoveTo' and 'LineTo' procedures
lines are drawn to generate a simple graph. One of the requirements is
to assign a different color per individual line,(6 colors). It did not
take long for me to discover that 'SetColor' and 'GetColor' required the
unit 'graph.tpw' which does not exist. I then wondered how 'LineTo'
worked since the procedure description states the same restriction as it does for the use of SetColor,(graph mode required). My background is primarily in C so just hacking through Pascal has been a challenge. Any suggestions how one could write a simple utility to assign a color prior to drawing a line would be a tremendous help. We really do not have the option to rewrite the program using Delphi or C++. Time restrictions limit that choice because this small utility uses pre-existing units that belong to a much larger application.

Thanks for any help and or advice,

EJ

Comments

  • : I recently was given a task to fix problems and enhance the features of
    : a small utility program. By using the 'MoveTo' and 'LineTo' procedures
    : lines are drawn to generate a simple graph. One of the requirements is
    : to assign a different color per individual line,(6 colors). It did not
    : take long for me to discover that 'SetColor' and 'GetColor' required the
    : unit 'graph.tpw' which does not exist. I then wondered how 'LineTo'
    : worked since the procedure description states the same restriction as it does for the use of SetColor,(graph mode required). My background is primarily in C so just hacking through Pascal has been a challenge. Any suggestions how one could write a simple utility to assign a color prior to drawing a line would be a tremendous help. We really do not have the option to rewrite the program using Delphi or C++. Time restrictions limit that choice because this small utility uses pre-existing units that belong to a much larger application.
    :
    : Thanks for any help and or advice,
    :
    : EJ
    :
    :
    First open the graph mode using InitGraph(). The call SetColor() with a color constant (0 to 15). Then you can draw the lines, possibly followed by SetColor() and MoveTo()/LineTo() to draw in another color. Finally return to the text mode with CloseGraph().
  • : : I recently was given a task to fix problems and enhance the features of
    : : a small utility program. By using the 'MoveTo' and 'LineTo' procedures
    : : lines are drawn to generate a simple graph. One of the requirements is
    : : to assign a different color per individual line,(6 colors). It did not
    : : take long for me to discover that 'SetColor' and 'GetColor' required the
    : : unit 'graph.tpw' which does not exist. I then wondered how 'LineTo'
    : : worked since the procedure description states the same restriction as it does for the use of SetColor,(graph mode required). My background is primarily in C so just hacking through Pascal has been a challenge. Any suggestions how one could write a simple utility to assign a color prior to drawing a line would be a tremendous help. We really do not have the option to rewrite the program using Delphi or C++. Time restrictions limit that choice because this small utility uses pre-existing units that belong to a much larger application.
    : :
    : : Thanks for any help and or advice,
    : :
    : : EJ
    : :
    : :
    : First open the graph mode using InitGraph(). The call SetColor() with a color constant (0 to 15). Then you can draw the lines, possibly followed by SetColor() and MoveTo()/LineTo() to draw in another color. Finally return to the text mode with CloseGraph().
    :


    I probably should have been a little more specific. The code was written using Borland's Pascal for Windows. What I can't do is include 'Graph' in the 'uses' listing. It appears that there was never a Graph.tpw offered and that the Procedures and Functions were only available for DOS applications, (InitGraph requires the use of the 'graph' unit and therefore generates; Error 3: Unknown identifier). I am still puzzled why 'LineTo' works without including a 'Graph' unit.

    Maybe I am incorrect so please feel free to straighten me out since I am far from a seasoned Pascal programmer.

    Thanks,
    EJ
  • : : : I recently was given a task to fix problems and enhance the features of
    : : : a small utility program. By using the 'MoveTo' and 'LineTo' procedures
    : : : lines are drawn to generate a simple graph. One of the requirements is
    : : : to assign a different color per individual line,(6 colors). It did not
    : : : take long for me to discover that 'SetColor' and 'GetColor' required the
    : : : unit 'graph.tpw' which does not exist. I then wondered how 'LineTo'
    : : : worked since the procedure description states the same restriction as it does for the use of SetColor,(graph mode required). My background is primarily in C so just hacking through Pascal has been a challenge. Any suggestions how one could write a simple utility to assign a color prior to drawing a line would be a tremendous help. We really do not have the option to rewrite the program using Delphi or C++. Time restrictions limit that choice because this small utility uses pre-existing units that belong to a much larger application.
    : : :
    : : : Thanks for any help and or advice,
    : : :
    : : : EJ
    : : :
    : : :
    : : First open the graph mode using InitGraph(). The call SetColor() with a color constant (0 to 15). Then you can draw the lines, possibly followed by SetColor() and MoveTo()/LineTo() to draw in another color. Finally return to the text mode with CloseGraph().
    : :
    :
    :
    : I probably should have been a little more specific. The code was written using Borland's Pascal for Windows. What I can't do is include 'Graph' in the 'uses' listing. It appears that there was never a Graph.tpw offered and that the Procedures and Functions were only available for DOS applications, (InitGraph requires the use of the 'graph' unit and therefore generates; Error 3: Unknown identifier). I am still puzzled why 'LineTo' works without including a 'Graph' unit.
    :
    : Maybe I am incorrect so please feel free to straighten me out since I am far from a seasoned Pascal programmer.
    :
    : Thanks,
    : EJ
    :
    In that case you need to use the windows GDI functions to draw what you wish to draw. To set the color you first need to create a Pen object (CreatePen()), then you can use that pen to draw the line. This method of programming is no different from C++, since the way the GDI functions work is language independent.
  • : : : : I recently was given a task to fix problems and enhance the features of
    : : : : a small utility program. By using the 'MoveTo' and 'LineTo' procedures
    : : : : lines are drawn to generate a simple graph. One of the requirements is
    : : : : to assign a different color per individual line,(6 colors). It did not
    : : : : take long for me to discover that 'SetColor' and 'GetColor' required the
    : : : : unit 'graph.tpw' which does not exist. I then wondered how 'LineTo'
    : : : : worked since the procedure description states the same restriction as it does for the use of SetColor,(graph mode required). My background is primarily in C so just hacking through Pascal has been a challenge. Any suggestions how one could write a simple utility to assign a color prior to drawing a line would be a tremendous help. We really do not have the option to rewrite the program using Delphi or C++. Time restrictions limit that choice because this small utility uses pre-existing units that belong to a much larger application.
    : : : :
    : : : : Thanks for any help and or advice,
    : : : :
    : : : : EJ
    : : : :
    : : : :
    : : : First open the graph mode using InitGraph(). The call SetColor() with a color constant (0 to 15). Then you can draw the lines, possibly followed by SetColor() and MoveTo()/LineTo() to draw in another color. Finally return to the text mode with CloseGraph().
    : : :
    : :
    : :
    : : I probably should have been a little more specific. The code was written using Borland's Pascal for Windows. What I can't do is include 'Graph' in the 'uses' listing. It appears that there was never a Graph.tpw offered and that the Procedures and Functions were only available for DOS applications, (InitGraph requires the use of the 'graph' unit and therefore generates; Error 3: Unknown identifier). I am still puzzled why 'LineTo' works without including a 'Graph' unit.
    : :
    : : Maybe I am incorrect so please feel free to straighten me out since I am far from a seasoned Pascal programmer.
    : :
    : : Thanks,
    : : EJ
    : :
    : In that case you need to use the windows GDI functions to draw what you wish to draw. To set the color you first need to create a Pen object (CreatePen()), then you can use that pen to draw the line. This method of programming is no different from C++, since the way the GDI functions work is language independent.
    :


    Thanks for the tip. I was able to draw colored lines to differentiate my graph parameters.

    Your help was excellent!
    EJ
  • its a .tpu file for TP7/BP7 v7 has dpmi version, but go get a bett crt unit or ask me for mine[video.pas]. Otherwise you get RT200 errors.

    I use FPC. It has graph and video units in the LCL with Lazarus.

    I don't know what install you have, but it doesn't look like an original installation disk, or it would have the unit you need. Tp7 always came with it and I've been using it since the adoption of the 286 on a 8086 w/turbo button.
  • its a .tpu file for TP7/BP7 v7 has dpmi version, but go get a bett crt unit or ask me for mine[video.pas]. Otherwise you get RT200 errors.

    I use FPC. It has graph and video units in the LCL with Lazarus.

    I don't know what install you have, but it doesn't look like an original installation disk, or it would have the unit you need. Tp7 always came with it and I've been using it since the adoption of the 286 on a 8086 w/turbo button.

    EDIT:

    attached the unit from FPOS. ITs GPL v2. use as you wish. delay loops are commented out, as I use them in my timer unit, but they do work, even if the timing is somewhat off.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories