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 

Unexpected %ws behavior

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



Joined: 13 Oct 2014
Posts: 1214
Location: Morrison, CO, USA

PostPosted: Wed Jun 21, 2017 10:44 pm    Post subject: Unexpected %ws behavior Reply with quote

I am building a display dialog dynamically and ran across an odd behavior with %ws.

It would appear that the character string being output is first being truncated (using something like trim()) and then that result is being used and subjected to the width parameter for %ws. The code below will demonstrate this behavior.

As a temp fix, I am examining the last character being output and, if it is a blank, then using "%ws " versus the simple "%ws". Not a perfect fix, but workable for now.

Code:
   use mswin
   integer k
    character*40:: text1='Start of text',text2='end of text '
   k = winio@("%ww[topmost,no_maxminbox,no_sysmenu,independent]%fn[Courier New]%bg&",rgb@(255L,255L,255L)) ! very small border ! casts_shadow,topmost,thin_border,no_caption
   k = winio@('1::%ws::This is as expected, displayed=as selected%nl&',text1(1:13))
   k = winio@('2::%ws::This should have 80 characters between ::%nl&',text1)
   k = winio@('3::%13ws::As expected%nl&',text1(1:13))
   k = winio@('4::%14ws::As expected%nl&',text1(1:12))
   k = winio@('5::%-14ws::Not left justified%nl&',text1(1:14))
    k = winio@('6::%-12ws::Not left justified%nl&',text2(1:12))
    k = winio@('%bt[Done]')
    end
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Thu Jun 22, 2017 5:40 pm    Post subject: Reply with quote

I have made a note of this.

Is it possible to get what you want by other means?

%ws is based on the C function printf and %s but I think that the author of ClearWin+ assumed that trailing spaces in a Fortran character string ought to be removed.

At first glance I am not sure about the "left justify". Is this not what one would expect?
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1214
Location: Morrison, CO, USA

PostPosted: Fri Jun 23, 2017 2:02 am    Post subject: Reply with quote

Yes, my temporary fix will do fine, just not in the general case (specifically handles a single space at the end of a string).

I can try some other possible fixes.

As far as the left-justify, no. this is not what would be expected. Looking at the %lv control as an example, left-justified text would never have a space at the front, unless one was in the string to begin with.
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1214
Location: Morrison, CO, USA

PostPosted: Fri Jun 23, 2017 2:07 am    Post subject: Reply with quote

I can "fool" it by placing a CHAR(0) at the end of the string to be output, thus forcing the issue.

Code:

   use mswin
   integer k
    character*40:: text1='Start of text',text2='end of text '
   k = winio@("%ww[topmost,no_maxminbox,no_sysmenu,independent]%fn[Courier New]%bg&",rgb@(255L,255L,255L)) ! very small border ! casts_shadow,topmost,thin_border,no_caption
   k = winio@('1::%ws::This is as expected, displayed=as selected%nl&',text1(1:13))
   k = winio@('2::%ws::This should have 80 characters between ::%nl&',text1)
   k = winio@('3::%13ws::As expected%nl&',text1(1:13))
   k = winio@('4::%14ws::As expected%nl&',text1(1:12))
   k = winio@('5::%-14ws::Not left justified%nl&',text1(1:14))
   k = winio@('6::%-12ws::Not left justified%nl&',text2(1:12))
   k = winio@('7::%-14ws::Not left justified%nl&',text1(1:16)//char(0))
   k = winio@('8::%-12ws::Not left justified%nl&',text2(1:14)//char(0))
    k = winio@('%bt[Done]')
    end

The newly added 7 and 8 examples respond exactly as expected because the width specifier is the minimum size.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support 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