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 

How to scroll to end of string in edit box automatically?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Apr 29, 2011 1:48 am    Post subject: How to scroll to end of string in edit box automatically? Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Fri Apr 29, 2011 8:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Fri Apr 29, 2011 8:16 am    Post subject: Reply with quote

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
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Apr 29, 2011 3:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Apr 29, 2011 9:23 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Apr 29, 2011 9:24 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Apr 29, 2011 9:24 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Fri Apr 29, 2011 9:54 pm    Post subject: Reply with quote

Yup, you can always ignore them in my experience, they have always gotten through appearances notwithstanding ...
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Apr 30, 2011 9:39 am    Post subject: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Sat Apr 30, 2011 12:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Sat Apr 30, 2011 3:54 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Sat Apr 30, 2011 5:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Sat Apr 30, 2011 6:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon May 02, 2011 6:13 pm    Post subject: Reply with quote

... 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
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Wed May 04, 2011 10:57 pm    Post subject: Re: Reply with quote

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. Smile

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
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