soccer jersey forums.silverfrost.com :: View topic - text colour printing to screen
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

text colour printing to screen

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
alangr



Joined: 24 Oct 2016
Posts: 47
Location: Oxford,UK and Athens, Greece

PostPosted: Mon Jan 09, 2023 5:41 pm    Post subject: text colour printing to screen Reply with quote

I am doing some very simple text handling and want to have a choice of colours with the results put on screen. In FTN77, I used COUP@ and this still works with FTN95 although I cannot find any reference to in in the User Notes and I have not been able to get the blinking aspect to work.

How should I put a character to the screen with a specified colour; and is it possible to make it blink?

Thanks.
_________________
Alan
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8012
Location: Salford, UK

PostPosted: Mon Jan 09, 2023 7:58 pm    Post subject: Reply with quote

Alan

I am guessing that you are writing to a DOS box. Perhaps you could post a short sample program that illustrates what you can do at the moment.

Writing coloured text in a Windows application is quite simple using ClearWin+ but text that blinks may be more tricky.

The lack of documentation for COUP@ etc. simply reflects the fact that such routines have become outmoded.
Back to top
View user's profile Send private message AIM Address
alangr



Joined: 24 Oct 2016
Posts: 47
Location: Oxford,UK and Athens, Greece

PostPosted: Tue Jan 10, 2023 10:21 am    Post subject: Reply with quote

Paul

I am writing to the screen from DOS but not formally a 'DOS box'. Essentially I am doing what I had done in FTN77. As an example this is intended to provide an alternating green/red character on screen. When I run this code step by step all is well. when I just run it the screen remains blank until about 15 seconds has passed and execution stops.

DO 10 K=1,15
COLR=2
CALL COUP@(TILE, COLR, IV, IH)
CALL SLEEP@(1)
COLR=4
CALL COUP@(TILE, COLR, IV, IH)
10 CONTINUE

If I had set one of the two COUP@ calls to colour black, I was hoping to make the character on screen blink slowly.

I quite understand the fact that the COUP@ is now outmoded but wish to do something like this using FTN95.

I have not used ClearWin+ yet; is this my way forward?

Sorry, coming to this from the past.
_________________
Alan
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8012
Location: Salford, UK

PostPosted: Tue Jan 10, 2023 1:00 pm    Post subject: Reply with quote

Alan

I was asking for a short working program that one could run without modification.

Maybe it would then be possible to transcribe this into ClearWin+ to get you started.
Back to top
View user's profile Send private message AIM Address
alangr



Joined: 24 Oct 2016
Posts: 47
Location: Oxford,UK and Athens, Greece

PostPosted: Tue Jan 10, 2023 4:08 pm    Post subject: Reply with quote

Paul

Here is the body of a program that works to produce a character alternating from green to red. With SDBG stepping through gives the desired effect. Running the program (F6) just gives a blank screen until the loop is complete.

PROGRAM TEST
*
INTEGER*2 K, IH, IV, COLR
CHARACTER TILE*1
*
CALL CLEAR_SCREEN@
*
TILE=CHAR(35)
IH=5
IV=7
*
DO 10 K=1,15
COLR=2
*
CALL COUP@(TILE, COLR, IH, IV)

CALL SLEEP@(1)
*
COLR=4
CALL COUP@(TILE, COLR, IH, IV)
*
CALL SLEEP@(1)
10 CONTINUE
*
STOP
*
END

I would welcome your comments of moving this to ClearWin+

Thanks
_________________
Alan
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8012
Location: Salford, UK

PostPosted: Tue Jan 10, 2023 8:46 pm    Post subject: Reply with quote

Here is a sample program that uses %tx to create the equivalent of a DOS box with coloured text. If it is relevant then I can think about how to make part of the text blink. It is also possible to write coloured text using %eb.

Code:
      winapp
      program main
      integer,parameter::NCOLS=80,NROWS=25,NCHRS=NCOLS*NROWS
      character text(NCOLS,NROWS),attr(NCOLS,NROWS)
      character(len=NCHRS) txt
      equivalence(text,txt)
      txt = " "
      attr = char(0)
      txt(1  :80)  = "First line"
      txt(81 :160) = "Second line"
      txt(161:240) = "Third line"
      attr(:,1) = char(1) !Attribute index for row 1
      attr(:,2) = char(2) !Attribute index for row 2
      attr(:,3) = char(3) !Attribute index for row 3
      iw = winio@('%80.25tx&',text,attr,NCOLS,NROWS)
      iw = winio@('%tc[blue]%ty[white]&') !Text colour and back colour for index 1
      iw = winio@('%tc[red]%ty[white]&')  !Text colour and back colour for index 2
      iw = winio@('%tc[white]%ty[black]') !Text colour and back colour for index 3
      end program
Back to top
View user's profile Send private message AIM Address
alangr



Joined: 24 Oct 2016
Posts: 47
Location: Oxford,UK and Athens, Greece

PostPosted: Wed Jan 11, 2023 8:15 am    Post subject: Reply with quote

Thank you for your response.

I will see what I can do working from your example. I think the flashing aspect is not a priority right now.

Thank you for your help.
_________________
Alan
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8012
Location: Salford, UK

PostPosted: Wed Jan 11, 2023 9:55 am    Post subject: Reply with quote

Here is a better sample for writing coloured text to a DOS box array of characters. Readers should note that writing text to a window is normally very simple as in iw = winio@("Hello World").

Code:
winapp
module txmod
 use clrwin
 integer,parameter::NCOLS=80,NROWS=25
 character(len=NCOLS)::lines(NROWS),attr(NROWS)
 integer ctrl
 
contains
 integer function dialog()
  integer i
  do i = 1,NROWS
   attr(i)  = repeat(char(0),NCOLS)
   lines(i) = " "
  end do
  iw = winio@('%pv%*.*tx&',NCOLS,NROWS,lines,attr,NCOLS,NROWS)
  iw = winio@('%tc[#0000ff]%ty[#ffffff]&') !char(1)
  iw = winio@('%tc[#ff0000]%ty[#ffffff]&') !char(2)
  iw = winio@('%tc[#ffffff]%ty[#000000]&') !char(3)
  iw = winio@('%lw',ctrl)
  dialog = iw
 end function

 subroutine WriteLine(lineNo, attrNo, str)
  integer lineNo, attrNo
  character(*) str
  lines(lineNo) = str
  attr(lineNo) = repeat(char(attrNo),NCOLS)
 end subroutine
 
end module txmod

program main
 use txmod
 iw = dialog()
 call WriteLine(1, 2, "First line")
 call WriteLine(2, 3, "Second line")
 call WriteLine(3, 1, "Third line")
 call window_update@(lines)
end program
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group