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 

Use of control character $ or \

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



Joined: 26 Oct 2017
Posts: 17
Location: University of Kassel,Germany

PostPosted: Sat Apr 07, 2018 1:46 pm    Post subject: Use of control character $ or \ Reply with quote

In the manual is declared:

A $ or \ edit descriptor is provided to facilitate the output of requests to the screen, without generating a new line. The descriptor must terminate the format specification. The comma preceeding \ is optional (like it is with the / descriptor). For example:

WRITE(*,100) K
100 FORMAT("Old K=",I5,"Enter new value",$)
END

My version:
CHARACTER NAMEIN*32
Write (KRW,'(" Filename of Input-File :>",$)')
Read (KRW,'(A)') NAMEIN

But this doesn't work. The cursor remains behind the output " Filename of Input-File :>" indeed, but when the new value is keyed in, the cursor jumps to the next line !?
What goes wrong?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 909

PostPosted: Sat Apr 07, 2018 3:20 pm    Post subject: Reply with quote

Things work as expected for me, if I set KRW = 2.
Code:
program krwx
integer :: krw=2
CHARACTER NAMEIN*32
Write (KRW,'(" Filename of Input-File :>",$)')
Read (KRW,'(A)') NAMEIN
print *,'String input: ',namein
end program


Code:
s:\LANG>ftn95 krw.f90 /link
[FTN95/Win32 Ver. 8.10.0 Copyright (c) Silverfrost Ltd 1993-2017]
    NO ERRORS  [<KRWX> FTN95 v8.10.0]
Creating executable: krw.EXE

s:\LANG>krw
 Filename of Input-File :>xyz
 String input: xyz

What is the value of KRW that you use, and how are you compiling, linking and running?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 1947
Location: Sydney

PostPosted: Sun Apr 08, 2018 2:43 am    Post subject: Reply with quote

Just replace kwr by * for terminal I/O
Code:
 CHARACTER NAMEIN*32
 integer :: k = 3
 
 Write (*,'(" Filename of Input-File :>",$)')
 Read  (*,'(A)') NAMEIN

 WRITE (*,100) K
 100 FORMAT("Old K = ",I0," : Enter new value ? ",$)
 read  (*,*) k
 
 END
Back to top
View user's profile Send private message
FK_GER



Joined: 26 Oct 2017
Posts: 17
Location: University of Kassel,Germany

PostPosted: Sun Apr 08, 2018 1:57 pm    Post subject: Reply with quote

Sorry, but I don't have presented the whole context. Here it is:
Code:
      winapp
      INCLUDE <windows.ins>
      LOGICAL EX
      CHARACTER*40 NAMEFS /'KIPEIN ** Input-Output-Control-Window **'/     
      CHARACTER NAMEIN*32
      INTEGER win,xsize,ysize,xpos,ypos
      COMMON /WINSET/ xpos,ypos,xsize,ysize
      DATA NDE/1/, NWR/4/, KRW/5/, NTB0/-9/, KSGR0/66/
C
      CALL INISET (0)  ! defines xpos,ypos,xsize,ysize
      win=create_window@(NAMEFS,xpos,ypos,xsize,ysize)
      CALL set_default_window@(win)
      CALL open_to_window@(KRW,win)
C
      Write (KRW,'(" Filename of Input-File :>",$)')
      Read (KRW,'(A)') NAMEIN
      INQUIRE (FILE=NAMEIN,EXIST=EX)
      IF (EX .EQV. .TRUE.)
     &  OPEN (UNIT=NDE,FILE=NAMEIN,ACTION='READ',STATUS='OLD',ERR=1101)
      .
      .

On the screen appears:
Filename of Input-File :>_The cursor is placed at this position, correct!
_But at the next keypress the cursor jumps into this line to the first position, not correct!

Example:
It should look like:
Filename of Input-File :>B1-C45.QUW

But it looks like:
Filename of Input-File :>
B1-C45.QUW

I've tried your proposals, but they don't work:
- KRW=2 does the same as KRW=5
- read(*,'(A)') produces an runtime error, because * is undefined in this context

Other proposals?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 909

PostPosted: Sun Apr 08, 2018 2:21 pm    Post subject: Reply with quote

It seems that the '$' format control is not implemented for output to windows in the same way as for the console.

In fact, what I see from running your program is that the cursor is at the beginning of the next line below the output as soon as the window is opened, before I press any key.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1812
Location: South Pole, Antarctica

PostPosted: Mon Apr 09, 2018 1:02 am    Post subject: Reply with quote

FK_GER wrote:
Other proposals?
Full demo of simple and much more elegant way done in one line
Code:
character NameIn*32

i=winio@('%ww Filename of Input File :>%15rs%ff%cn%bt[OK]',NameIn)

end
Just substitute your line with READ.... with this line. If you like to close the window also with Enter not just with mouse click then the first line has to be this
Code:
i=winio@('%ac[Enter]&','exit')
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
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