|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Fri Apr 29, 2011 1:48 am Post subject: How to scroll to end of string in edit box automatically? |
|
|
I have an edit box I'm using as a status-reporting box in FTN95. I implement it by using:
CHARACTER*32000 statstg
i=winio@('%64.10eb[hscrollbar,vscrollbar]',statstg,32000)
As the program runs, every now and then I post new messages in this box. To do this, I remove any NULL (CHAR(0)) from the end of statstg, append a linefeed (CHAR(10)), then append the new message, and finally append a NULL. Then I call window_update@(statstg) to display the entire string of messages, including the new message.
This is working well, for the first ten sentences or so. But then the sentences start scrolling off the visible area in the box. I can bring them back by clicking and dragging the vertical scroll bar, and that works too.
But is there a way I can have the system automatically "drag the scroll bar", so that each time a message is posted then entire string moves up until the new message is visible at the bottom of the box, without the user having to click and drag the scrollbar manually each time?
I'd imagine the solution might (or might not) involve doing an ADJUSTR(statstg) to move all the sentences to the end of that (very long) statstg, and then simply scroll all the way to the bottom each time somehow. A good solution, but not a perfect one - the scrollbar at the right side of the edit box, would become really teeny, and moving it even a millimeter would cause huge jumps in the string, as though the string contained many hundreds of sentences.
I guess I have two questions:
1.) How do I make the system scroll the vertical scrollbar automatically, to the very end of the 32,000-character string if necessary (i.e. if the characters are right-justified in the string)?
2.) How do I make the system scroll only to the end of the printing characters in the string, if they are left-justified in the string? Currently they are terminated with a CHAR(0) - does that help?
Thanks, all! |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Fri Apr 29, 2011 8:11 am Post subject: |
|
|
Hi, here is just an alternative but very easy way for what you want to do - I use this method in several applications:
Code: | handle = create_window@('Info',100,100,700,500)
call open_to_window@(6,handle)
.
.
.
write(6,'(A)')'message text'
.
.
.
call destroy_window@(handle) ! at the end of the programme |
Regards - Wilfried |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Fri Apr 29, 2011 8:16 am Post subject: |
|
|
If you want to store the report, then expand the code like following:
Code: | open(77, file='report.txt,err=...,status='unknown')
handle = create_window@('Info',100,100,700,500)
call open_to_window@(6,handle)
.
.
.
write(6,'(A)')'message text'
write(77,'(A)')'message text'
.
.
.
call destroy_window@(handle) ! at the end of the programme
close(77) |
Regards, Wilfried |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2391 Location: Yateley, Hants, UK
|
Posted: Fri Apr 29, 2011 3:04 pm Post subject: |
|
|
Of course, the simplest way of doing this (a "hack") is to just WRITE(*,*).
You could also try what is confusingly termed a "Clearwin window", generated with the format code %N.Mcw rather than by Wilfried's create_window@ route (although they get you to the same place eventually, %cw is more versatile and more compatible with winio@). One of the problems with your %eb is that the contents can be edited by a user - the contents of a clearwin window can be copied, but not changed, which is more in line with your description of what you are doing. You can embed the %cw in a window with other contents, or put it in its own movable window with a %ca caption (and %ww and %sy etc). Clearwin windows within a more complicated window can have a pivot attached to them (%pv%cw) so that they are resizable.
I've only used a clearwin window once, but it does always scroll to the end when you write to it, and, because you can attach a Fortran unit to it, you don't have to bother with the complexities of adding text to the end - just do a Fortran formatted write - as Wilfried suggests.
Some time ago, text facilities in clearwin windows were enhanced, which you will find in the log of updates.
If you read the FTN95.CHM file, you will be confused (possibly - I was!). Basically, the description of clearwin windows reads as though it has survived, largely unmodified, since the origins of Clearwin, when the acme of converting a Fortran program to Windows was to be able to run it with output going to a standard Windows text window! Skip the stuff on "clearwin windows" until you have mastered %cw, and then read it understanding what the description is (i.e. a bit of archaeology!).
Eddie |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Fri Apr 29, 2011 9:23 pm Post subject: Re: |
|
|
Wilfried Linder wrote: | Hi, here is just an alternative but very easy way for what you want to do - I use this method in several applications:
Code: | handle = create_window@('Info',100,100,700,500)
call open_to_window@(6,handle)
.
.
.
write(6,'(A)')'message text'
.
.
.
call destroy_window@(handle) ! at the end of the programme |
Regards - Wilfried |
Aw, that's SO sweet.... does everything I've been trying to do for months with that window.
Text in this window comes out in System font. Is there a way to make it Arial font? I tried
i=winio@('%fn[Arial]&')
followed later by
i=winio@('%sf&')
....but no luck, it's still in System font. I tried this both before and after the "create_window@ - open_to_window@" group, and also before and after the actual WRITE statement. Neither changed the font successfully.
But boy, is it nice to have a workable Status window! Thank you! |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Fri Apr 29, 2011 9:24 pm Post subject: Re: |
|
|
Oops, duplicate post, sorry
Last edited by Little-Acorn on Fri Apr 29, 2011 9:26 pm; edited 1 time in total |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Fri Apr 29, 2011 9:24 pm Post subject: Re: |
|
|
Triplicate post! Now I'm really sorry!
(I kept getting a strange "DEBUG" response from the system when posting, so I thought it hadn't accepted my post, and tried a few more times) |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Fri Apr 29, 2011 9:54 pm Post subject: |
|
|
Yup, you can always ignore them in my experience, they have always gotten through appearances notwithstanding ... |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2391 Location: Yateley, Hants, UK
|
Posted: Sat Apr 30, 2011 9:39 am Post subject: |
|
|
From v 5.50:
ClearWin+: A new option has been added for %cw called [local_font] that causes %cw to use the current %fn and %ts.
Regards
Eddie |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Sat Apr 30, 2011 12:46 pm Post subject: |
|
|
If you want to have the output in a proportional font like Arial, just add the following line before (!) the create_window@ command:
call set_default_proportional_font@()
You can find some more information about the so-called Clearwin windows in the Clearwin manual.
Regards - Wilfried |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Sat Apr 30, 2011 3:54 pm Post subject: Re: |
|
|
Wilfried Linder wrote: | If you want to have the output in a proportional font like Arial, just add the following line before (!) the create_window@ command:
call set_default_proportional_font@()
You can find some more information about the so-called Clearwin windows in the Clearwin manual.
Regards - Wilfried |
Thanks, Wilfried! I'll try that on Monday.
After that command, then should the winio@('%fn[Arial]&') command work? Or does that set_default command merely start using its own proportional font, that I may or may not be able to change (Arial vs. Calibri vs. etc.)? |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Sat Apr 30, 2011 5:24 pm Post subject: |
|
|
As far as I know, there are two main possibilities for Clearwin windows:
set_default_to_fixed_font@() sets the "system fixed" font
set_default_proportional_font@() sets the "system" font
There is also a subroutine set_default_font@(hfont) with hfont is a handle to an existing font, but I've never used this possibility and no idea about it, sorry...
Regards - Wilfried |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Sat Apr 30, 2011 6:09 pm Post subject: |
|
|
Hey - I tried what Eddie mentioned before, and it seems that something like this may help you:
Code: | integer*4 ctrl
.
.
.
j = winio@('%lw%sy[3d_thin]%fn[ARIAL]%ts%120.40cw[local_font]',ctrl,.96D0,6) |
%lw is to leave the window open - you can close it with ctrl = 0.
%fn sets the font, %ts the text size
%cw opens the Clearwin window, "6" is the Fortran standard output unit
Have a nice weekend - Wilfried |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2391 Location: Yateley, Hants, UK
|
Posted: Mon May 02, 2011 6:13 pm Post subject: |
|
|
... and also (from v6.00):
Quote: | ClearWin+: The standard callback COPY has now been implemented for %cw |
which is even better news.
Eddie |
|
Back to top |
|
|
Little-Acorn
Joined: 06 Jul 2008 Posts: 111 Location: San Diego
|
Posted: Wed May 04, 2011 10:57 pm Post subject: Re: |
|
|
Little-Acorn wrote: | Wilfried Linder wrote: | If you want to have the output in a proportional font like Arial, just add the following line before (!) the create_window@ command:
call set_default_proportional_font@()
You can find some more information about the so-called Clearwin windows in the Clearwin manual.
Regards - Wilfried |
Thanks, Wilfried! I'll try that on Monday.
After that command, then should the winio@('%fn[Arial]&') command work? Or does that set_default command merely start using its own proportional font, that I may or may not be able to change (Arial vs. Calibri vs. etc.)? |
Hmmm, it didn't work.
I put:
CALL set_default_proportional_font@()
just before the create_window@ command. No change, the box appears as before, but still its text is in System font. I guess System font *is* a proportional font.
Then I added the statement:
CALL set_default_font@("Arial")
...after the set_proportional_font@ subroutine call, thinking that might persuade it to use Arial font. But that didn't work either: the box's text is still in System font.
Also tried those two statements before the actual WRITE( command to the new box. Still no luck: Text comes out in System font.
My biggest problem with System font, is that it is (or appears to be) boldfaced. This is very distracting. I hope to use a font (such as Arial) which is not boldfaced unless I tell it to be boldfaced.
I'll dig thru the manuals on these new subroutines. But I guess I'm open to suggestions.
ON EDIT:
I even tried erasing the above statements and putting in:
CALL SET_DEFAULT_TO_FIXED_FONT@
....before the create_window@ command, just to see if I could change ANYTHING about the text inside the new status box. Still no luck: Its text still comes out in System font, which is apparently a proportional font. |
|
Back to top |
|
|
|
|
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
|