HP Forums

Full Version: TEXTOUT_P: export graphic?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi,
I've this function
Code:

labelmat()
BEGIN
  RECT_P();
  TEXTOUT_P("Labels of the matrices", 10, 20, 3, RGB(255, 0, 0));
  TEXTOUT_P("SL: Straight Line method", 10, 40, 3, RGB(0,255,0));
  TEXTOUT_P("Depr. expence | Accum. dep. year-end", 10, 60);
  TEXTOUT_P("| Book value y-end | Remaining val", 10, 75);
  TEXTOUT_P("DB: Declining Balance method", 10, 95, 3, RGB(0,255,0));
  TEXTOUT_P("Dep rate | D. expence | Accum. d. year-end", 10, 110);
  TEXTOUT_P("| Book val y-end | Remaining val", 10, 125);
  TEXTOUT_P("SOYD: Sum of the Years Digits method", 10, 145, 3, RGB(0,255,0));
  TEXTOUT_P("Depr. Base | D. rate | D. expence ", 10, 160);
  TEXTOUT_P("| Acc. dep. year-end | Book val y-end ", 10, 175);
  TEXTOUT_P("| Remaining val", 10, 190);
  WAIT;
  smenu();
END;

I would like to export the graphic (or the text inside graphic) into a var, or make it available for the user after the program ending.
Is there a way to do this?

Salvo
Hi Salvo,

If I understand your question, check out the BLIT or BLIT_P commands. They use the 10 graphic variables G0-G9. You can copy the contents from a source to a target grob using these vars. Pixel information can be exchanged between the graphics vars, such as the contents of a textout_p() command.

-Dale-
(05-27-2015 10:55 AM)DrD Wrote: [ -> ]Hi Salvo,

If I understand your question, check out the BLIT or BLIT_P commands. They use the 10 graphic variables G0-G9. You can copy the contents from a source to a target grob using these vars. Pixel information can be exchanged between the graphics vars, such as the contents of a textout_p() command.

-Dale-

I Dale,
thank you, I'm seeing in the User Guide this commands.
Here from command line with G0 I get the last screen of Home...
Now I must understand how to save the TEXTOUT_P's screen into (i.e) G1 via those BLIT commands...

I'm "studying" about your advice Smile

Salvo
I understand your thinking. It's a little tricky at first, (for me, anyway). Once information gets set up in G1, (for example, which I tend to use as a temporary scratch pad), you can "Blit" it over to the viewable G0 screen, and "Freeze" it or "Wait" for further activity. Essentially, this would allow switching between 10 screens of information, creating the possibility of some very dynamic action!
(05-27-2015 11:24 AM)DrD Wrote: [ -> ]I understand your thinking. It's a little tricky at first, (for me, anyway). Once information gets set up in G1, (for example, which I tend to use as a temporary scratch pad), you can "Blit" it over to the viewable G0 screen, and "Freeze" it or "Wait" for further activity. Essentially, this would allow switching between 10 screens of information, creating the possibility of some very dynamic action!

I'm trying using "BLIT_P(G1, G0);" after the TEXOUT_P lines and first of the WAIT;
I get in G1 two copies of the screen (see files attached), too small...
You need to use rect_p(G1) to clear that grob, or (see help) create a rectangle for your specific need, by adding the x,y coordinates to the rect-p(). You can clear all, or a specific part of a graphic variables 320 x 240 pixel map.

The best thing to say is that you must consider every detail on each graphic object to avoid undesirable artifacts (clutter).
(05-27-2015 05:21 PM)DrD Wrote: [ -> ]You need to use rect_p(G1) to clear that grob, or (see help) create a rectangle for your specific need, by adding the x,y coordinates to the rect-p(). You can clear all, or a specific part of a graphic variables 320 x 240 pixel map.

The best thing to say is that you must consider every detail on each graphic object to avoid undesirable artifacts (clutter).

I tried: RECT_P(G1); RECT_P(); ...
then I got still two elements, when input G1 from command line...
Why to little copies instead that one? Smile
If the two copies are resident on G0, and only one is coming from G1, you could clear G0 before doing the blit_p(G1,G0), or via rect_p(G0). You could also erase grob G1, via rect_p(G1)

If the two copies are coming in via blit_p(G1,G0), you could clear G1 first, via rect_p(G1). You can decide how much rectangular space you really need to transfer to G0 via blit_p(G1, 0,0,320,240,G0,0,0,320,240), using any suitable x,y coordinates within your range of interest.

If this info isn't helpful, you can send me your code snippet, and I'll try to figure out what is happening there. In short, you can specify what rectangular sector(s) you want to clear, or transfer via rect_p() or blit_p(), by use of the x,y pixel coordinates of the specific grob variable.
(05-27-2015 07:22 PM)DrD Wrote: [ -> ]...
If this info isn't helpful, you can send me your code snippet, and I'll try to figure out what is happening there. In short, you can specify what rectangular sector(s) you want to clear, or transfer via rect_p() or blit_p(), by use of the x,y pixel coordinates of the specific grob variable.

I get always two copy, however, kindly, try this code:
Code:

EXPORT labelmat()
BEGIN
  RECT_P();
  TEXTOUT_P("Labels of the tables", 85, 10, 5, RGB(255, 0, 0));
  LINE_P(10,35,300,35, RGB(0,0,255));
  TEXTOUT_P("SL: Straight Line method", 10, 45, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P("| Depr. expence | Accumul. dep. at year-end |", 5, 65);
  TEXTOUT_P("| Book value at year-end | Remaining value    |", 5, 80);
  TEXTOUT_P("DB: Declining Balance method", 10, 100, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P("| Dep. rate | D. expence | Accum. d. y-end |", 5, 115);
  TEXTOUT_P("| Book value at year-end | Remaining value |", 5, 130);
  TEXTOUT_P("SOYD: Sum of the Years Digits method", 10, 150, 3, RGB(0,0,0),250, RGB(0,255,0));
  TEXTOUT_P("| Depreciation Base | Dep. rate | D. expence |", 5, 165);
  TEXTOUT_P("| Accumulated dep. y-end | Book val y-end   |", 5, 180);
  TEXTOUT_P("| Remaining value |", 5, 195);
  BLIT_P(G1, G0);
  WAIT;
END;
Salvo,

I get only one copy on G0, as expected from a quick read through your code. In your pixel commands you are not specifying a graphics variable, so it defaults to G0. At the end of your code, you use the blit_p() to transfer from G0, all your textout_p() source data, to G1 (the target grob). Since no other activity with G1 takes place, essentially it is like an assignment: G1:=G0. But you aren't doing anything further with G1, so nothing else takes place with it.

Since you are getting two copies, and I am only getting one, it may be that you have a memory corruption event going on, and need to reset your calc. This happens once in awhile, and whenever things get unexplainable, I usually start there.

-Dale-
You're not getting two copies, it is just showing you the content in 2d mode of your graphic variable from input and the output. If you don't want to see the graphic at the end of the execution, return 1 or something like that instead of returning the graphic as a result.
(05-27-2015 08:08 PM)DrD Wrote: [ -> ]Salvo,

I get only one copy on G0, as expected from a quick read through your code. ...

-Dale-

(05-27-2015 09:09 PM)Tim Wessman Wrote: [ -> ]You're not getting two copies, it is just showing you the content in 2d mode of your graphic variable from input and the output. If you don't want to see the graphic at the end of the execution, return 1 or something like that instead of returning the graphic as a result.

Dale, Tim,
thank you.
I would like to have only one copy saved in G1 after the program end.
How must I change the BLIT_P() command? or Am I do other thing?

Salvo
Either do all your drawing on G1, and then display it at the end on G0 (your screen), or else draw to G0, and copy into G1 if you plan on keeping it around. You will need to size your G1 before you use it!

Code:

EXPORT labelmat()
BEGIN
  DIMGROB_P(G1,320,240); //or whatever you want the size to be
  RECT_P(G1);
  TEXTOUT_P(G1,"Labels of the tables", 85, 10, 5, RGB(255, 0, 0));
  LINE_P(G1,10,35,300,35, RGB(0,0,255));
  TEXTOUT_P(G1,"SL: Straight Line method", 10, 45, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P(G1,"| Depr. expence | Accumul. dep. at year-end |", 5, 65);
  TEXTOUT_P(G1,"| Book value at year-end | Remaining value    |", 5, 80);
  TEXTOUT_P(G1,"DB: Declining Balance method", 10, 100, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P(G1,"| Dep. rate | D. expence | Accum. d. y-end |", 5, 115);
  TEXTOUT_P(G1,"| Book value at year-end | Remaining value |", 5, 130);
  TEXTOUT_P(G1,"SOYD: Sum of the Years Digits method", 10, 150, 3, RGB(0,0,0),250, RGB(0,255,0));
  TEXTOUT_P(G1,"| Depreciation Base | Dep. rate | D. expence |", 5, 165);
  TEXTOUT_P(G1,"| Accumulated dep. y-end | Book val y-end   |", 5, 180);
  TEXTOUT_P(G1,"| Remaining value |", 5, 195);
  BLIT_P(G0, G1);
  WAIT;
END;

Or copy into G1 at the end.

Code:
EXPORT labelmat()
BEGIN
  RECT_P();
  TEXTOUT_P("Labels of the tables", 85, 10, 5, RGB(255, 0, 0));
  LINE_P(10,35,300,35, RGB(0,0,255));
  TEXTOUT_P("SL: Straight Line method", 10, 45, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P("| Depr. expence | Accumul. dep. at year-end |", 5, 65);
  TEXTOUT_P("| Book value at year-end | Remaining value    |", 5, 80);
  TEXTOUT_P("DB: Declining Balance method", 10, 100, 3, RGB(0,0,0),210, RGB(0,255,0));
  TEXTOUT_P("| Dep. rate | D. expence | Accum. d. y-end |", 5, 115);
  TEXTOUT_P("| Book value at year-end | Remaining value |", 5, 130);
  TEXTOUT_P("SOYD: Sum of the Years Digits method", 10, 150, 3, RGB(0,0,0),250, RGB(0,255,0));
  TEXTOUT_P("| Depreciation Base | Dep. rate | D. expence |", 5, 165);
  TEXTOUT_P("| Accumulated dep. y-end | Book val y-end   |", 5, 180);
  TEXTOUT_P("| Remaining value |", 5, 195);
  DIMGROB_P(G1,320,240);
  BLIT(G1,G0);
  WAIT;
END;
(oops, I think I doubled with Tim. Sorry about that! What Tim said^^^)!

When the code is run on either VC or HC, (for me) the program behaves exactly as expected.

It issues each textout_p() or line_p() to the default GO; and finally transfers a copy of the screen content to G1. The original G0 content remains on screen until after the 'WAIT' automatically times out (after one minute), returning -1 to the home screen.

While running this program, if you are seeing something else on screen, (other than the screen capture I sent in the last post), during the 'WAIT' time out period, it would be something I would not expect. Any previous G0 content should have been wiped clean when the program executed the RECT_P(), and nothing from G1 gets transferred back into G0, so the only thing that should show up is one copy of the textout_p() commentary.

Are you saying you are looking at G1 (after the program has completed?), if so, please let us know how you are doing that. I thought you meant that the program resulted in two copies of the output.
(05-27-2015 10:03 PM)Tim Wessman Wrote: [ -> ]Either do all your drawing on G1, and then display it at the end on G0 (your screen), or else draw to G0, and copy into G1 if you plan on keeping it around. You will need to size your G1 before you use it!...

ok!
I'm learning a bit more from your advice...

however, with the second solution I get still two copies, and with the first an error...
(05-27-2015 10:06 PM)DrD Wrote: [ -> ]Are you saying you are looking at G1 (after the program has completed?), if so, please let us know how you are doing that. I thought you meant that the program resulted in two copies of the output.

after the program end, I typed G1 in the command line, getting the "two copies" output...
The chunk of the code come from my "Depreciation" program (here or in the Software Library Forum), that contains the same functions (labelmat() ) with a last line smenu() to call the menu of the program (a choice command)...
Oh, ok. I totally missed that point. The graphic variables contents are visible only when 'blitted' to G0, and displayed on the graphics screen, as far as I know. We both will learn from this if you can view them some other way!

Check out page 376 (under :=)and page 492 (mid-page) of the User Guide. (Basis for my understanding).
(05-27-2015 10:37 PM)DrD Wrote: [ -> ]Oh, ok. I totally missed that point. The graphic variables contents are visible only when 'blitted' to G0, and displayed on the graphics screen, as far as I know. We both will learn from this if you can view them some other way!

Check out page 376 (under :=)and page 492 (mid-page) of the User Guide. (Basis for my understanding).

you are right, Dale (and also Tim), maybe it not possible to export the graphic screen as I imagined...
I'm thinking about another way... Smile

In the meantime I've improved Depreciation with new calculations for "partial year"...

Salvo
(05-27-2015 10:19 PM)salvomic Wrote: [ -> ]after the program end, I typed G1 in the command line, getting the "two copies" output...

What do you get if you type 1+1 and press ENTER? 1+1 on the left, and 2 on the right.

So when you type G1 and press ENTER... G1 on the left, and G1 on the right. :-)
(05-28-2015 12:10 AM)Tim Wessman Wrote: [ -> ]What do you get if you type 1+1 and press ENTER? 1+1 on the left, and 2 on the right.

So when you type G1 and press ENTER... G1 on the left, and G1 on the right. :-)

yes Tim, I know Smile
I would have only export the graphic for future reference...

Salvo
Reference URL's