PE Programming for dummies

Anything QL Software or Programming Related.
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

PE Programming for dummies

Post by Andrew »

I started to learn some PE programming using EasyPtr.
I want to have a menu created with Mawdraw that uses a different font and char size (a fat font). Well, it was wasy to use a different fon - but how on earth do I use a different char size?

Code: Select all

1550   OPEN #mainch%,'con_'
1590   MDRAW #mainch%,'win1_mymenu_men', 50, 25
1610   menu = MWDEF(#mainch%)
1620   CHAR_USE#mainch%,CrtAddr,0:CSIZE#mainch%,1,0
1840   MAWCLEAR #menu, 1
1850   MAWDRAW #menu, 1, c$, 0, 0,0,14,10,0,0
The CSiZE in line 1620 does nothing - MAWRAW resets the char size to 0,0
How can I have only the menu rendered by MAWDRAW in CSIZE 1,0, while having all other menu windows and items still in csize 0,0?


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: PE Programming for dummies

Post by tofro »

The answer is simple: You can't (at least not easily). The only item that can have CSIZEs different from 0,0 is an info window.

You can open a window on top of any PE menu item with MWINDOW, then draw into it however you like - The change is however only temporary.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: PE Programming for dummies

Post by pjw »

tofro wrote:The answer is simple: You can't (at least not easily). The only item that can have CSIZEs different from 0,0 is an info window.<>
I think you may find that things have changed a bit since last you looked. You can now use different csizes with Application sub Windows. Or perhaps thats what you meant by "not easily": It cant be done with EasyMenu; youd have to poke the values into the Menu Definition or the Working Definition.
Andrew, get the latest Qptr manual from Wolfgang Lenerz' site. The information you need is there (but it wont tell you how to do it!)
Sorry, dont have the time now to answer more comprehensively. Ive never used this myself either, so dont have any routines to share..


Per
dont be happy. worry
- ?
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: PE Programming for dummies

Post by Andrew »

pjw wrote:
tofro wrote:TAndrew, get the latest Qptr manual from Wolfgang Lenerz' site. The information you need is there (but it wont tell you how to do it!)
Sorry, dont have the time now to answer more comprehensively. Ive never used this myself either, so dont have any routines to share..
I read EasyPtr manual and the latest QPtr manual several times over the last 2 weeks. Neither seems to be user-friendly - and both gave me a lot of grey hair.


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: PE Programming for dummies

Post by pjw »

I agree with you there. It gets easier.. :shock:

Anyway, I found this from Wolfgang (packaged by me. Seems I may have used it after all!).

First do a MAWSETUP, then call the routine below, then MAWDRAW:

Code: Select all

rem + ------------------------------------------------------------------------ +
rem |<                               Set_csizes                               >|
rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
rem |                  set the csizes for menu appsub windows                  |
rem |                                                                          |
rem | params:                                                                  |
rem |    channel%                                                              |
rem |      the channel number, which must be the same one as used for MAWDRAW  |
rem |      or MAWSETUP. THIS DOES NOT DEFAULT TO ANYTHING, you MUST            |
rem |      supply this parameter correctly.                                    |
rem |    num%                                                                  |
rem |      the appsub number, starting at 1 for the first appsub wdw           |
rem |    x_csize%                                                              |
rem |       the x csize (0 ... 3), same as for the CSIZE command               |
rem |    y_csize%                                                              |
rem |       the y csize (0 or 1), same as for the CSIZE command                |
rem |                                                                          |
rem |    If there is any error in the parameters, this just gives up silently  |
rem |    without generating an error                                           |
rem + ------------------------------------------------------------------------ +
rem | V0.01, WL, SMSQ/E V3.19++                                                |
rem + ------------------------------------------------------------------------ +
:
def proc set_csizes (channel%,num%,x_csize%,y_csize%)
local appsub_nbr%,appsub
  appsub= MWDEF(#channel%)                      : rem the working definition
  appsub_nbr%=peek_w(appsub+110)                : rem nbr of appsub wdws
  if appsub_nbr% < num% or num% < 1: return     : rem wrong appsub number
  appsub=peek_l(appsub+112)                     : rem point to appsub list
  appsub=peek_l(appsub+4*(num%-1))              : rem get pointer to appsub wdw
  if x_csize% > -1 and x_csize% < 4
      poke appsub+38,x_csize%                   : rem set size
  endif
  if y_csize% > -1 and y_csize% < 2
      poke appsub+39,y_csize%                   : rem set size
  endif
end def set_csizes
:
:
Remember: The menu must be dimensioned (by you) to take the csizes you intend to use.
Try it! I dont know if it works..


Per
dont be happy. worry
- ?
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: PE Programming for dummies

Post by Andrew »

pjw wrote:I agree with you there. It gets easier.. :shock:
Anyway, I found this from Wolfgang (packaged by me. Seems I may have used it after all!).
Thank you very much! This helps a lot.

For the current project (learning project) I already used a window overlayed on the menu - it works, but it offends my programming taste :)
But the final scope is to port QL Commander to PE and there it's mandatory to have the csize set for the menu window, to use the scroll - hence my question.


Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: PE Programming for dummies

Post by Derek_Stewart »

Hi,

QPTR ptogramming is not easy, but it lacks good examples on how ptogramme the PE Windows.

Wolfgang 's web site has many PE fames and utilites with source code, which worth a look.


Regards,

Derek
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: PE Programming for dummies

Post by Andrew »

Thank you DIlwyn for the examples and source code you sent me! They were invaluable in understanding how EasyPtr works. I have used them in my program.
My first PE program is almost ready. I have attached the source code in the zip file.
Almost because:
- it runs perfectly in BASIC
- it took 2 minutes to compile it with QLIBERATOR and works, as long as I load the _men from disk
- spent 2 days to embed the _men files in the _obj and failed miserably! I read the manual 100 times and I still do not understand how to use APPMAN. I tried to create the Extension+Appendix - created several ... Program compiles but crashes on run. I have no idea what I am doing wrong. :( :( :(

Please explain me how to use APPMAN and what (and how) must I create there - to compile succesfully with QLiberator.
Charmap1.jpg
Charmap2.jpg
Later Edit: attachement removed - download final version here viewtopic.php?p=45034#p45034
Last edited by Andrew on Wed Dec 29, 2021 7:25 pm, edited 1 time in total.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: PE Programming for dummies

Post by tofro »

Yep, appman is a bit awkward to handle, but still very useful. Small Recipe:
  • Open appman
  • Add your menus ("load"->"Menu", assign some proper names (last column). Your Window should look like this:
    APPMAN0.png
  • Save as an extension (Set "Command" to "APPA0", which should be the default, then save as an appendix (e.g. "charmap_app", FILES->SAVE->APPENDIX). Don't try and mess with the "append" option or something - That's a bit of a nuisance in compiled programs, IMHO.
  • LRESPR the app file you made to check it.
  • PRINT appa0('charmap') (Or whatever you called a menu in the app file) must return a reasonable value. x = FOPEN ("con") : MDRAW #x,APPA0("charmap") must display the menu - otherwise, repeat previous steps until you succeed.
  • Up to here, you got it working in S*BASIC. Now you need to be able to use it in a compiled program. This is what I do with Turbo: "200 REMark %%dos2_charmap_app,0,60". For liberated programs, you would probably use something like 400 REMark $$asmb=win1_dev_charmap_app0_app,0,60 (The 60 works for me, but may depend on your appman version. In case 60 doesn't work, provide your _app file for analysis, please)
Hope this helps!


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: PE Programming for dummies

Post by Andrew »

tofro wrote:Yep, appman is a bit awkward to handle, but still very useful. Small Recipe:
  • Open appman
  • Add your menus ("load"->"Menu", assign some proper names (last column). Your Window should look like this: APPMAN0.png
  • Save as an extension (Set "Command" to "APPA0", which should be the default, then save as an appendix (e.g. "charmap_app", FILES->SAVE->APPENDIX). Don't try and mess with the "append" option or something - That's a bit of a nuisance in compiled programs, IMHO.
  • LRESPR the app file you made to check it.
  • PRINT appa0('charmap') (Or whatever you called a menu in the app file) must return a reasonable value. x = FOPEN ("con") : MDRAW #x,APPA0("charmap") must display the menu - otherwise, repeat previous steps until you succeed.
  • Up to here, you got it working in S*BASIC. Now you need to be able to use it in a compiled program. This is what I do with Turbo: "200 REMark %%dos2_charmap_app,0,60". For liberated programs, you would probably use something like 400 REMark $$asmb=win1_dev_charmap_app0_app,0,60 (The 60 works for me, but may depend on your appman version. In case 60 doesn't work, provide your _app file for analysis, please)
Hope this helps!
Done! And I still get the same errors when I run the compiled program...
After Lrespr win1_dev_charmap_char_app x = FOPEN ("con") : MDRAW #x,APPA0("charmap") displays the menu
I have attached the char_app (just delete the .zip extension)

What APPMAN version are you using?
I use v4.02, latest version from EasyPtr4 package from Dilwyn's site - and it refuses to run on QPC2 in high colour modes!!!! It only runs in QL colors mode

Later Edit: I noticed that qlib_ext is not corectly linked to the obj when I use QLiberator 3.45 - but it is linked when I use Qliberator 3.36.
This may be because the init and table values are not correct for v3.45

Code: Select all

40 REMark $$asmb=win1_QLiberator_qlib_ext,0,12
I have attached the qlib_ext (just delete the .zip extension) Please , can you tell me the correct values?
Attachments
Qlib_ext.zip
(1.81 KiB) Downloaded 118 times
char_app.zip
(3.45 KiB) Downloaded 135 times


Post Reply