Silverfrost Forums

Welcome to our forums

Library with screen location(x,y)

31 Mar 2023 6:20 #30129

My question is:

(1.) Is there an include library that deals with e.g. locate(x,y) and (2.) If so, could you please give a very simple code example of how the library in question facilitates coding e.g. locate(10,6)? I.e., what then that simple main (using) program could look like?

Many thanks.

31 Mar 2023 7:56 #30131

There is no locate() function that I can see. What is it supposed to do?

Perhaps a more detailed statement of the question is in order?

31 Mar 2023 9:26 #30133

Bill, I did reply, but my post has disappeared. I am receiving error messages from the SilverFrost desk. Will try again tomorrow. Patrick.

31 Mar 2023 9:44 #30134

I had a look at the messages without logging first and I did get to se my response message to you / if I log in properly first, I don't see my response message. So there is something fishy going on in the provider's software it would seem.

31 Mar 2023 10:12 #30136

You should look at the documentation for FTN95 for the drawing primitives. I pulled this list below directly from the Plato HELP file.

DRAW_LINE_BETWEEN@ Draws a straight line between two points.

DRAW_CHARACTERS@ Draws text.

DRAW_ELLIPSE@ Draws an ellipse.

DRAW_FILLED_ELLIPSE@ Fills an ellipse.

DRAW_FILLED_POLYGON@ Fills a polygon.

DRAW_FILLED_RECTANGLE@ Fills a rectangle.

DRAW_POLYLINE@ Draws a number of connected straight lines.

DRAW_RECTANGLE@ Draws a rectangle.

DRAW_POINT@ Sets a pixel colour.

SET_LINE_STYLE@ Sets attributes for line drawing.

SET_LINE_WIDTH@ Sets the width for line drawing.

This is probably what you are after.

31 Mar 2023 11:06 (Edited: 1 Apr 2023 5:38) #30137

I want to be able to place something on the screen, ad hoc, by means of a locate(x,y) statement. I am not wanting to draw lines and what not. What would be really perfect, would be to be able to put an image on screen from within a FTN program, as a backdrop, then place stuff on it, in the way just now described. Then you would have visual FTN. Dead simple! Creating an image with a tuppence graphics program, then incorporating that image in a FTN program, to be projected on-screen, is something I've been unable to find how to do. It would be revolutionary. You'd have visual FTN (or visual C) without all the fuss of e.g. visual C#.

This is how you put things on screen in C:

void locate(short x, short y) ; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); }

No sweat at all.

1 Apr 2023 12:08 #30138
program t
use clrwin
implicit none
integer iw
integer, external :: cb_add, cb_clear
iw = winio@('%mn[Exit]&','Exit')
iw = winio@('%bg[blue]&')
iw = winio@('%^bt[Add something]%^bt[Clear]&',cb_add,cb_clear)
iw = winio@('%nl%gr[white]&',500,500)
iw = winio@('')
end program t

integer function cb_add()
use clrwin
implicit none
integer, external :: cb1
integer iw
integer x, y
character(len=40) text
common x,y,text
  x = 50
  y = 25
  text = 'This is some text'
  iw = winio@('x%rd%nly%rd%nl%rs&',x,y,text)
  iw = winio@('%nl%bt[Cancel]%ta%^bt[Apply]&',cb1)
  iw = winio@('')
  cb_add = 2
end function cb_add

integer function cb1()
use clrwin
implicit none
integer iw
integer x,y
character(len=40) text
common x,y,text
  call draw_characters@(text,x,y,rgb@(1,1,1))
  cb1 = -1
end function cb1

integer function cb_clear()
use clrwin
implicit none
  call draw_filled_rectangle@(0,0,500,500,rgb@(255,255,255))
  cb_clear = 2
end function cb_clear
1 Apr 2023 4:51 #30140

Hi Kenneth, well, this is truly amazing and rather a different ballgame than simply Fortran. I wonder how you know how to do all that! I will have to experiment to find out which text does what. Thank you very much for responding in this way. I am impressed. Patrick

1 Apr 2023 10:31 #30141

The example uses the Silverfrost Clearwin+ library.

Documentation (from 2000, based largely on FTN77 programming) which explains the basic functionality can be found here:

https://silverfrost.com/manuals/clearwin.pdf

Updated information is in the documentation that can be searched from within Plato via the Help menu.

A comprehensive set of examples illustrating many features of ClearWin+ can be found here:

https://gitlab.com/silverfrost/clearwin-examples

1 Apr 2023 11:11 #30142

Kenneth, Thank you very much for the reference, Patrick.

1 Apr 2023 12:36 #30143

The examples are about graphs, was that your intention?

1 Apr 2023 5:45 #30144

Look at the examples in the Controls Demo folder.

1 Apr 2023 8:47 #30145

Yes, I will do that. Thank you for the tip.

2 Apr 2023 10:39 #30146

What about this:

https://www.silverfrost.com/manuals/fortran-and-the-art-of-windows-programming.pdf

Requires minimal knowledge of Fortran.

Eddie

2 Apr 2023 12:09 #30147

Hi, re your reference: I have downloaded it. Thank you for drawing my attention to it. Patrick

3 Apr 2023 9:18 #30149

In an effort to code ad analogiam Kenneth's code

program main use clrwin implicit none integer :: iw integer :: x = 10 integer :: y = 5 iw = winio@('%nl%gr[white]&',500,500) call draw_filled_rectangle@(0,0,500,500,rgb@(255,255,255)) call draw_characters@('Hello World',x,y,rgb@(1,1,1)) end program main

What is wrong? / How to get it to work? Apologies if this is very stupid.

4 Apr 2023 12:23 #30150

Your program has a couple of faults. No matter, we've all done this at one time or another (for me about a week ago).

Your code should read:

        WINAPP
	program main
	use clrwin
	implicit none
	integer :: iw,control=0
	integer :: x = 10
	integer :: y = 5
	iw = winio@('%nl%gr[white]&',500,500)
	iw = winio@('%lw',control)
	call draw_filled_rectangle@(0,0,500,500,rgb@(255,255,255))
	call draw_characters@('Hello World',x,y,rgb@(1,1,1))
	end program main

Note that I declared an integer 'control' that is required for a %lw.

The %lw is required so the window can be 'created' and the program continues to the next lines afterward. Yet, the window remains!!

It is on those remaining lines that you can do what you wish. You cannot draw on a surface until it is created. It is not created until the window is actually built (hence the %lw).

Suggestion: Instead of 'use clrwin', you can 'use mswin'. That will get you additional capabilities later on.

Also WINAPP is a good thing to use at the top of your main program to insure all the appropriate windows setup routines are called.

4 Apr 2023 4:43 #30156

Hi, your corrected code works nicely. Thank you. How do I get rid of the black ugly compiler output frame behind the new white frame? Calling clear_screen@ doesn't do the job. And how do I make the font bigger in the new white frame?

4 Apr 2023 6:22 #30157

program main use clrwin implicit none

integer :: iw,control=0 integer, dimension(2)::loc = (/20,50/) iw = winio@('%nl%gr[white]&',500,500) iw = winio@('%lw',control) call draw_filled_rectangle@(100,100,500,500,rgb@(255,255,255)) !here call locate(loc) end program main

subroutine locate(loc) use clrwin integer,intent(in)::loc(2) !there call draw_characters@('Hello World',loc(1),loc(2),rgb@(1,1,1)) end subroutine

Hello World is being printed, But how do I pass 'Hi there' form !**here **to !**there **and cause the called statement to print 'Hi There'

Q: How do i make the font bigger? Q: How could I get rid of the big black compiler output frame, behind the newly created white frame?

4 Apr 2023 7:52 #30159

One of a few possibilities:

winapp
program main
use clrwin
implicit none

integer :: iw,control=0
integer, dimension(1:2)::loc = (/20,50/)
iw = winio@('%nl%gr[red]&',500,500)
iw = winio@('%lw',control)
call draw_filled_rectangle@(100,100,500,500,rgb@(255,255,255))
call SCALE_FONT@(2.d0)
call locate(loc,'Hello World')
end program main


subroutine locate(loc,text)
use clrwin
integer,intent(in)::loc(2)
character(len=*) text
call draw_characters@(text,loc(1),loc(2),rgb@(1,1,1))
end subroutine
Please login to reply.