Silverfrost Forums

Welcome to our forums

Use of control character $ or \\

7 Apr 2018 12:46 #21754

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?

7 Apr 2018 2:20 #21757

Things work as expected for me, if I set KRW = 2.

program krwx
integer :: krw=2
CHARACTER NAMEIN*32
Write (KRW,'(' Filename of Input-File :>',$)')
Read (KRW,'(A)') NAMEIN
print *,'String input: ',namein
end program


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?

8 Apr 2018 1:43 #21763

Just replace kwr by * for terminal I/O 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
8 Apr 2018 12:57 #21769

Sorry, but I don't have presented the whole context. Here it is:

      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?

8 Apr 2018 1:21 #21771

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.

9 Apr 2018 12:02 #21773

Quoted from FK_GER Other proposals? Full demo of simple and much more elegant way done in one line 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

i=winio@('%ac[Enter]&','exit')
Please login to reply.