|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
FK_GER
Joined: 26 Oct 2017 Posts: 35 Location: University of Kassel,Germany
|
Posted: Sat Apr 07, 2018 1:46 pm Post subject: Use of control character $ or \ |
|
|
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 |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sat Apr 07, 2018 3:20 pm Post subject: |
|
|
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 |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Sun Apr 08, 2018 2:43 am Post subject: |
|
|
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 |
|
|
FK_GER
Joined: 26 Oct 2017 Posts: 35 Location: University of Kassel,Germany
|
Posted: Sun Apr 08, 2018 1:57 pm Post subject: |
|
|
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 |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Sun Apr 08, 2018 2:21 pm Post subject: |
|
|
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 |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2815 Location: South Pole, Antarctica
|
Posted: Mon Apr 09, 2018 1:02 am Post subject: |
|
|
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 |
|
|
|
|
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
|