Silverfrost Forums

Welcome to our forums

print special characters

1 Jun 2012 1:12 #10251

Hello, special characters on screen works fine, how to print special characters?

WINAPP 
IMPLICIT NONE 
INCLUDE <windows.ins> 
INTEGER*4 i,w
character*80 s(4)
integer*4 k,j
integer hnd1
data hnd1/1/
s(1) = '{sum n=1;{infinity}}{divide l;n{sup 2}}={divide {pi}{sup 2};6}'
i = winio@('%ca[Equatation]%bg[grey]&')
w = winio@('%ob%eq@%cb&',s(1),200,100)
w = winio@(' ')
k=open_printer@(hnd1)
j=select_graphics_object@(hnd1)
call size_in_points@(6,6)
call draw_characters@(s(1),1000,2000,rgb@(255,0,0))
k=close_printer@(hnd1) 
end

Many thanks Johann

1 Jun 2012 4:19 #10255
  1. Capture from screen as a graphic, and paste that onto the page (which is already in graphics mode). If it is always the same thing that you print, then consider creating a bitmap and including it in your Resources.
  2. Select the Symbol font, and by judicious choice of position and character size generate your equation.
  3. Create your own font and use that - some applications have their own maths fonts that you might be able to use.
  4. Open printer for use with html ('html_printer_open') and put your equation in between <equation> and </equation> tags. HTML is useful because you have access to different character sizes, bold, italic, underlining etc from ordinary Fortran formatted writes.

I'm sure that this isn't a complete list.

Eddie

4 Jun 2012 6:50 #10267

Hallo Eddie, how to change the size and exact position of the 'sigma' character? It should have the same size und vertical location like the word 'result'. call size_in_pixel and call size_in_points does'nt work. thanks Johann

WINAPP 
IMPLICIT NONE 
INCLUDE <windows.ins> 
INTEGER*4 i
character*80 s(1)
s(1) = '{sigma}'
i = winio@('%ca[Equatation]%bg[grey]%fn[arial]&')
!  call size_in_points@(0,0)
!  call SIZE_IN_PIXELS@( 200,200 )
i = winio@('%tsresult &',1.0D0)
i = winio@('%eq@&',s(1),20,20)
i = winio@('%sdx,Rd%`sd&')
i = winio@('%ts [N/mm2]&',1.0D0)
i = winio@(' ')
end
4 Jun 2012 7:46 #10268

I am not sure what you want but it may be easier like this

WINAPP 
IMPLICIT NONE 
INCLUDE <windows.ins> 
INTEGER*4 i 
character*80 s(1) 
s(1) = '{sigma}' 
i = winio@('%ca[Equatation]%bg[grey]%fn[arial]&') 
!  call size_in_points@(0,0) 
!  call SIZE_IN_PIXELS@( 200,200 ) 
i = winio@('%tsresult &',1.0D0) 
!i = winio@('%eq@&',s(1),20,20) 
i = winio@('%fn[Symbol]s%sf&') 
i = winio@('%sdx,Rd%`sd&') 
i = winio@('%ts [N/mm2]&',1.0D0) 
i = winio@(' ') 
end 
4 Jun 2012 8:33 #10270

Thank you very much, it's exact what I mean, so easy when you know it. It would be great, if you could give me a easy example like this to print this line on a printer.

Johann

4 Jun 2012 1:35 #10271

Paul has modified your code to use my suggestion 2 above. Those Clearwin format codes work on your screen windows. To get the same thing on your printer, you need to open the graohics printer either by having a standard callback (say from a button) of 'PRINTER_OPEN' or 'PRINTER_OPEN1' or 'GPRINTER_OPEN', or by using one of the subroutines in the library OPEN_PRINTER@ etc. Then you go through the process of constructing your graphic part by part using the subroutines in the graphics part of the library. You will certainly want SELECT_FONT@, and probably you will get a better result by using SIZE_IN_POINTS@ than in pixels (it is the other way round on the screen in a %gr area. If you have selected the Symbol font you will get Greek characters when you write ordinary text using CALL DRAW_CHARACTERS@.

Eddie

5 Jun 2012 12:40 #10274

Hello, now I understand and both, screen and printer work fine with special characters.

Tank you very much for your great and quick help.

Johann

6 Jun 2012 8:37 #10279

Paul, i think this still needs some fine tuning for positioning of subscripts and specifically superscripts which look very ugly. Look at the code

 character*80 s(1) 
 s(1) = '{sigma}' 
 i = winio@('%ca[Equatation]%bg[grey]%fn[arial]&') 
 i = winio@('%ts&',1.0D0) 
 i = winio@('where %fn[Symbol]s%sf&') 
 i = winio@('%sdx%`sd&') 
 i = winio@('%su1/2%`su represents%ff&') 

 i = winio@('where %fn[Symbol]s%sf&') 
 i = winio@('%su1/2%`su&') 
 i = winio@('%sdx%`sd represents%ff&') 

 i = winio@('where  %sfa%sf&') 
 i = winio@('%su1/2%`su&') 
 i = winio@('%sdx%`sd represents') 


 end
7 Jun 2012 6:18 #10285

I can look at this but this kind of thing is very tricky. Anything I do in this kind of area can easily break someone's work-around.

8 Jun 2012 5:36 #10288

Hi Paul,

You don't break the workaround if you introduce new format codes to set sizes of equation characters and sub/super script offsets, but keep the default behaviour as is. (Or a format code that implies 'equations in new style'). Whether or not this is a priority I cannot judge, but suspect that it is not.

Eddie

8 Jun 2012 6:10 #10289

Introducing new two-letter codes makes Clearwin less and less intuitive to read. It would be better to make new three-letter Clearwin++ which gives more freedom to stay less cryptic lexically

8 Jun 2012 3:30 #10291

Dan,

I don't agree. All Clearwin today is done with 2 letter codes, and changing this is a problem. Whether or not Clearwin should have used 3 or more ab initio is a debate to which there is no answer, but a 1 letter 'sequence' gives definitely too few possibilities, and the 26x26 two-letter combinations produces vastly more codes than seem to be needed - and it is not possible to visit 'alternative history' at this point.

There are many alternatives to a %?? format code, and they include:

a subroutine call an additional parameter in the options list for %ww or %sy a modifier such as ` which has not been used

There aren't many Clearwin codes that are not generally mnemonic for a native English speaker (home territory to Clearwin!) although I do keep wanting to use %fs as 'font size' instead of its real purpose after using %fn.

However, the general principle of not wanting to break anything is a good one, which is why I often dissent from some of the 'future Fortran' proposals to declare something obsolete, and get frustrated by some of the changes to Windows (see other posts, including re GET_FILTERED_FILE@). One of the benefits of Fortran is the ability to use code written a long time ago, and I still regularly use code I wrote in 1970 (and every year since, with few exceptions).

Regards

Eddie

8 Jun 2012 8:43 (Edited: 9 Jun 2012 4:30) #10295

Eddie,

First, this is not a Fortran, Fortran means simplicity, not overcrypting. Here despite most of codes are very good abbreviations from English you still have to rely on your memory to cut the options.

If this was Fortran it would be dead long ago due to its almost encrypted nature. It is literally impossible to remember all the two-letter codes. Better to say - well, you may memorize them when you heavily programming in Clearwin, but then you get 2-3 years interruption while using them very occasionally and then guess what? You start over looking into help. I've done that 3-4 times ! The codes always leave too much guessing. I was using CWP for 15 years, my couple codes have 30+ thousand of CWP codes each and i still very often look into the help to make sure that's the right code.

Other GUI builders took another more verbose approach which is kind of opposite corner. Their functions may have very many letters. Winteracter for example. People when they have very large codes tend to use larger variables which perfectly serves the purpose of self-documenting. Look at Linux sources - they sometimes use 63 character variables! And that's the key psychological point. We will not lose too much if we will type a bit more. We will not forget passwords if it is very long but very logical - we will forget them it will be short 6-8 numbo-letter soup. I am glad by the way that FTN95 is probably the only Fortran compiler which allows superlong variables much longer then 31 letter, i am very happy developers made it and use them permanently lately.

From the point of simplicity having too short codes is actually not a gain but a loss in readability. I hope that making at least three-letter codes will allow Clearwin+ to be expanded an additional order of magnitude not losing readability and 'memorability'.

I was making this list just as an example for all to look and found myself looking into help for 3/4 of them JUST TO MAKE SURE i do not mix them with something else! I marked some codes which clearly gain readability with the stars, and added minus when 2-letter codes look better. I guess sometimes third letter could be a number to make an options for 2-letter codes. The ptoposed abbreviations could be improved to be more close to natural English words we use for that specific purpose. Clearly some current two-letter codes run out of steam to find best equivalent. And with time things will be even worse - imagine 5 times more codes - it will be end of the game.

In short - three letter codes leave you with much less guessing what they are, they could be more systematically grouped, and they allow further natural language expansion of Clearwin+ to Clearwin+++++. 😃

%ac - %acc accelerator %ap - %abp absolute position %aw - %acw attach child window %bc - %bco or %btc button color %bd - %brd borders %bf - %bfn or %bld bold font %bg - %bgc background color (for everything else) ** %bh - %bbh bubble help %bi - %bic button icon %bk - %rmb right mouse button ** %bm - %bmp bitmap - %br - %bar bar * %bt - %btn button * %bv - %tre tree view * %bx - %box box * %ca - %cap caption * %ob - %obx open box %cb - %cbx close box %cc - %ccw Control Closure of Window %ch - %chw child window %cl - %pal palette colors ** %cn - %cnt center text %co - %cob control box of %rd, %rf * %cu - %cur cursor shape %cv - %ctr control variable %cw - %cww Clearwin Window %dc - %dfc default cursor %dd - %spi spin wheel Integer * %df - %spf spin window flating point %de - %daw disable windows * %dl - %rpt repeating call of windows * %dr - %drp drop file %dw - %dgb draw graphics box %dy - %mvy move in y direction %eb - %ebx edit box %el - %ecb edit combo box %eq - %eqn equation ** %es - %esc esc %ew - %exw exit Windows %fb - %fnb font for buttons * %fd - %fn5 font for Win95 %ff - %ffd form feed - %fh - %fnW font from Windows ** %fl - %fpl FP limits *** %fn - %fnt font ** %fr - %frm frame ** %fs - %dir directory to save * %ft - %flt filter text * %ga - %grb or %gar %gd - %grd grid * %gf - %ghf get handle of font %gi - %gif add gif image * %gp - %gpw get position of window * %gr - %grw graphics window %he - %hpp help position %ht - %hpt hypertext %hw - %hnw handle window %hx - %hsb horizontal scrolbar ** %ib - %imb image buttom %ic - %ico icon * %if - %foc focus * %il - %ilm integer limit - %it - %ita italic %lc - %hlc handle of last control * %ld - %led LED symbol %ls - %lbx list box %lv - %lst list vew %lw - %kep keep open %mg - %msg Windows messages %mi - %mic minimize icon %mn - %mnu menu %ms - %msb multi-selection box %mv - %mov for tracking window movement %nc - %cnm class name ** %nd - %nod no down %nr - %nor no right %ns - %nos no screen saver %nl - %nwl new line %ob - %obx open box %og - %ogl OpenGL ** %pb - %pbx parameter box ** %pd - %pnd UK Pount symbol ** %pl - %spl or %spw SIMPLEPLOT window %pm - %pop popum menu * %ps - %pps property sheet * %pv - %rsz resize *** %rb - %rbt radiobutton %rd - %rdi read integer variab *** %re - %edi editor box ** %rf - see above read FP (%rdf, %rdi, %rdc) %rj - %rjy right justify - %rm - %pmn or %ppm - popup menu - %rp - %rel relative position %rs - %rdc see above read character (%rdf, %rdi, %rdc) %sc - %ini initial call window %sd - %sub subscript *** %sf - %sfn standard font %sh - %psh property sheet %si - %sti standard icon %sl - %sld slider %sm - %smn system menu %sp - %pos position of window %ss - %sav save settings %st - %str string %su - %sup superscript ** %sv - %ssv screen saver %sy - %stl style ** %sz - %szw size of window ** %ta - %tab tab * %tb - %bmb bit map button ** %tc - %col or %clr or %tcl text color %th - %tth tooltip help %ti - %tbi task bar icon %tl - %tln tab length %ts - %tsz text size %tt - %tbt text button ** %tv - %tre tree vew %tx - %txc colored text %ul - %und underline %uw - %api to all windows API * %vx - %vsb vertical screol bar %wc - %wrc write character variab %wd - %Wri write integer variab %we - %wre write real variab %wf - %wrf write real variab in F format %wg - %wrg write real variab in G format %ws - %wrc %wre char variab in A format %wp - %wlp wallpaper bitmap %wx - %Whx write hex ** %ww - %win window *

8 Jun 2012 11:35 #10298

Dan,

The 3-letter codes won't happen, as there look to be far more pressing issues. I will reserve my judgement on what you have said here - but 2 letters is enough for me. Like you, I have to frequently revisit help. If you don't use Plato, the help for Clearwin is lots of clicks away - it is much more convenient in Plato.

Eddie

9 Jun 2012 4:59 #10301

I would not mind even if the CWP codes were 4 or 5 letters long either (or even user definable names and lengths when the CWP code ends say with underscore. You could write then abbreviating code as you think it is comfortable for you - %it_ %ital_ or %italic_ or %pl_, %spl_ or %simpleplot_ and such codes will be both readable and even better visible) eliminating guessing almost completely and approaching normal human, scientific or IT people language.

Yes, we can make a world record creating extremely functional window full of options just in one single Fortran line but creating it and then reading causes your brain damage.

i=winio@('%ww%mi[i]%ca[win]%wp[a]%mn[File[Exit]]%th%dd%il%cn%`bg[yellow]%?7rd[index]%ff%nl%cn%^bm[e]%ff','exit',1,1,0,10,j,'exit') 

http://img97.imageshack.us/img97/5143/clearwin7.gif

I guess, if Paul thinks to introduce Clearwin+ to other compilers and hopes for its explosive adoption then he should think in advance that users will ask for expansion of Clearwin+ in many other areas including internet, tablets, parallel computing and 2-letter restriction will kill CWP from the inside as some bad design decision which then will be impossible to fix.

Right now when users base is small it is easy to write translator for legacy Clearwin+ which will automatically substitute two letter codes in existing sources of users to any new options it may adopt.

Here is continue of the list above just to think about it as a general idea:

%gd - %grd grid * %gf - %ghf get handle of font %gi - %gif add gif image * %gp - %gpw get position of window * %gr - %grw graphics window %he - %hpp help position %ht - %hpt hypertext %hw - %hnw handle window %hx - %hsb horizontal scrolbar ** %ib - %imb image buttom %ic - %ico icon * %if - %foc focus * %il - %ilm integer limit - %it - %ita italic %lc - %hlc handle of last control * %ld - %led LED symbol %ls - %lbx list box %lv - %lst list vew %lw - %kep keep open %mg - %msg Windows messages %mi - %mic minimize icon %mn - %mnu menu %ms - %msb multi-selection box %mv - %mov for tracking window movement %nc - %cnm class name ** %nd - %nod no down %nr - %nor no right %ns - %nos no screen saver %nl - %nwl new line %ob - %obx open box %og - %ogl OpenGL ** %pb - %pbx parameter box ** %pd - %pnd UK Pount symbol ** %pl - %spl or %spw SIMPLEPLOT window %pm - %pop popum menu * %ps - %pps property sheet * %pv - %rsz resize *** %rb - %rbt radiobutton %rd - %rdi read integer variab *** %re - %edi editor box ** %rf - see above read FP (%rdf, %rdi, %rdc) %rj - %rjy right justify - %rm - %rdm read messages %rp - %rel relative position %rs - %rdc see above read character (%rdf, %rdi, %rdc) %sc - %ini initial call window %sd - %sub subscript *** %sf - %sfn standard font %sh - %psh property sheet %si - %sti standard icon %sl - %sld slider %sm - %smn system menu %sp - %pos position of window %ss - %sav save settings %st - %str string %su - %sup superscript ** %sv - %ssv screen saver %sy - %stl style ** %sz - %szw size of window ** %ta - %tab tab * %tb - %bmb bit map button ** %tc - %col or %clr or %tcl text color %th - %tth tooltip help %ti - %tbi task bar icon %tl - %tln tab length %ts - %tsz text size %tt - %tbt text button ** %tv - %tre tree vew %tx - %txc colored text %ul - %und underline %uw - %api to all windows API * %vx - %vsb vertical screol bar %wc - %wrc write character variab %wd - %Wri write integer variab %we - %wre write real variab %wf - %wrf write real variab in F format %wg - %wrg write real variab in G format %ws - %wrc %wre char variab in A format %wp - %wlp wallpaper bitmap %wx - %Whx write hex ** %ww - %win window *[/img]

9 Jun 2012 3:40 #10304

Dan,

As always, food for thought. There is no end to it. For example, %ew is not really 'exit Windows' it is in fact 'execute this callback if the user exits Windows', or %etcbituew'. Perhaps I just prefer the shorter form.

Just because you can do something doesn't mean that you should, or must, do it. A certain amount of pain has convinced me not to put too many Clearwin format codes in a single WINIO@ call. My rule is not more than one code that has a callback and/or grey code, but any number of %ff and %nl are OK. For controls that need qualifying (spinwheels etc) the codes for that can go in too. This simplifies putting in comments, which are an important part of programming.

For repetitive things such as setting background colours, etc, I put the WINIO@s in a subroutine. Finding that the WINIO@ calls could be spread over several subroutines was an early revelation to me. When creating a main window, I also have subroutines for the menu construction, the toolbars, any graphics area, startup and closedown. In the menu subroutine for example, the only format code is %mn, so it isn't very difficult to work out what it does in a subroutine called 'BUILD_MENUS'. This approach does require SAVE in each associated routine.

Some format codes are hardly memorable because they are only called once per program (e.g. %ew). But, in a routine called CLOSEDOWN_ACTIONS, containing only %cc and %ew, they aren't difficult to remember. (Same for STARTUP_ACTIONS with %sc and %dr etc).

Eddie

10 Jun 2012 2:36 #10306

Well, i see why you oppose, because you've already made steps to be more verbose then CWP is. I sometimes do program same way like you but mostly like in this example above, because my code i develop and improve 30+ yeas is already barely manageable. Alas all people are different as we know if you ever borrowed the notes of lessons from your university classmates. Paul was probably using shorthand at his time 😃. For me these two-letter CWP codes are difficult in the sense that i always expect large field of possible decryptions - complication also comes if English was not your first language and you are using almost all possible CWP codes

And ultimately how many people would be here if our Fortran commands looked like this 😃

CJ for CONJG CN for COMMON CE for Continue etc.etc.etc CH CL CM DA DM DO DT EQ ED EX FL FN GO IF IM IN IX LG LN MA MI ML MV ML MO OP PG PR PS RD RL RA SB SI SQ ST TA TH WH WR

and programmers always guessing:

RD is Real*8 or Read ? PR - PARAMETER, PRINT or POINTER ? FL - Float or Forall ? MV - is MaxVal or MinVal ? CO - CONTINUE, CONTAINS or CONJG ? AB - ABS or ABORT ? 😃

If seriously - the two-letter CWP codes was a good experiment. And i will tell you i love it. But as CWP matures its syntax should be changed to offer less cryptic language ideally keeping compatibility with the older one.

10 Jun 2012 7:54 #10308

Historical note: I did not design or write the original ClearWin+. However the format codes do make sense as an extension of the C function printf.

11 Jun 2012 4:06 #10313

5% probably do, which with time will go to 0.5% as soon as all 26x26 symbols will be used. Also i'd not use word 'extensions', because even C printf is much more verbose then CWP, the 'shortcuts' or 'abbreviations' are better words. They have some roots deep in the English language but generally they are just the two-letter codes, the words of lower level then anything ever existed before computer language. When you see C printf or Fortran WRITE even if you do not know language you do not need your brain translator

printf ('Float number: %F', pricetag); write(*,'(F6.2)') pricetag

But let's those who do not know Clearwin+ tell even looking into manual which one below (or none of them) is used for the same purpose. Those who know CWP can also try to count the time they will need to decrypt. i=winio@('Float number: %fl', pricetag) i=winio@('Float number: %rf', pricetag) i=winio@('Float number: %ps', pricetag) i=winio@('Float number: %re', pricetag) i=winio@('Float number: %gf', pricetag i=winio@('Float number: %ft',pricetag i=winio@('Float number: %if',pricetag

28 Jun 2012 12:09 #10439

Just for curious hopeless users the answer is

i=winio@('Float number: %rf', pricetag)

Surprised? By the way works even better then %wf allowing dynamic change with window_update@ .

/* Yea, we need more users of this compiler.

Please login to reply.