- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi to everybody,
i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:
Tiefe cC Hrte RA
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
For me interesting is only column one and two (Tiefe and Cc).
I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...
Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.
SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE
LOGICAL checked
INTEGER ind
CALL ImportAsciiOpenFileNameStruktur('Whle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*) ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF
RETURN
END
FIND HERE THE SUBROUTINE "ZeigeErgebnisse"
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
I hope somebody is able give me an advice or correct my code...
Thanks
Marco
i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:
Tiefe cC Hrte RA
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
For me interesting is only column one and two (Tiefe and Cc).
I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...
Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.
SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE
LOGICAL checked
INTEGER ind
CALL ImportAsciiOpenFileNameStruktur('Whle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*) ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF
RETURN
END
FIND HERE THE SUBROUTINE "ZeigeErgebnisse"
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
I hope somebody is able give me an advice or correct my code...
Thanks
Marco
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - kaffee46
Hi to everybody,
i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:
Tiefe cC Hrte RA
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
For me interesting is only column one and two (Tiefe and Cc).
I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...
Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.
SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE
LOGICAL checked
INTEGER ind
CALL ImportAsciiOpenFileNameStruktur('Whle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*) ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF
RETURN
END
FIND HERE THE SUBROUTINE "ZeigeErgebnisse"
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
I hope somebody is able give me an advice or correct my code...
Thanks
Marco
i am building a QuickWIN Application and at the moment i am trying to read in a ASCII-File (*.txt).
The file looks like this:
Tiefe cC Hrte RA
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
For me interesting is only column one and two (Tiefe and Cc).
I tried to use an existing code of an example application, but unfortunately it does not work.
There is no error when building the program, but the screen is empty...
Find below my code for "reading the file" and the subroutine to write the ASCII-File to the screen.
SUBROUTINE ImportAscii( checked )
USE ImportAsciiGeneral
USE COMDLG32
IMPLICIT NONE
LOGICAL checked
INTEGER ind
CALL ImportAsciiOpenFileNameStruktur('Whle zu ladende Ergebnisdatei'C )
IF ( GetOpenFileName( OF ) ) THEN ! OK , Cancel?
! Read Data
OPEN (FUNIT, FILE=TxtFile)
DO ind = 1, dimV
READ (FUNIT,*) ! xV(ind), yV(ind)
END DO
CLOSE (FUNIT)
! Show Data
CALL ZeigeErgebnisse
END IF
RETURN
END
FIND HERE THE SUBROUTINE "ZeigeErgebnisse"
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
I hope somebody is able give me an advice or correct my code...
Thanks
Marco
Remove the ! from READ(FUNIT,*) !XV(IND), YV(Ind)
as you have made your variables into a comment!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - anthonyrichards
Remove the ! from READ(FUNIT,*) !XV(IND), YV(Ind)
as you have made your variables into a comment!
Hi,
thanks, but if i do this, the is "Error Window" if i try to open the ASCII File and the program crashes.
If i only use
READ(FUNIT,*)
the following is shown in the screen:
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
0.000 0.000
The values of my ASCII FIle are not shown...
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think we need to see what is in the module IMPORTASCIIGENERAL as it appearsthat all your variables are declared there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
[cpp]program testread
implicit none
INTEGER*4 I,J,TT
INTEGER*4 NDIS,NLEC,NCON
REAL*4 TIEFE(1000)
REAL*4 cC(1000)
REAL*4 Harte(1000)
REAL*4 RA(1000)
J = 0
NDIS = 1
OPEN (NDIS, FILE = 'ASCIIDATA.TXT')
DO WHILE (.NOT. EOF(1))
J = J + 1
READ (1, *) TIEFE(j), cC(J), Harte(j), RA(j)
WRITE(NCON,*) cC(j)
END DO
CLOSE(NDIS)
end program testread
[/cpp]
ASCIIDATA.txt:
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you have the names of the columns in the first row...
program main
real, dimension(25):: x,y
integer:: i
open(unit=33,file='foo.txt',action='read') !...
i=-1
do while (.not.eof(33))
i=i+1
if (i==0) then
read(33,*)
else
read(33,*) x(i),y(i) !...iostat
endif
enddo
end program
program main
real, dimension(25):: x,y
integer:: i
open(unit=33,file='foo.txt',action='read') !...
i=-1
do while (.not.eof(33))
i=i+1
if (i==0) then
read(33,*)
else
read(33,*) x(i),y(i) !...iostat
endif
enddo
end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.
Hi and thanks for your replies,
i tried to built the program similar to mavliks "testread", unfortunately it did not work. I think i made some mistakes because i tried to use my subroutine "ZeigeErgebnisse". Mavlik only used "write". Can somebody help me to integrate the "call ZeigeErgebnisse" SUBROUTINE Mavliks code?
Furthermore more i need some help with the subroutine "ZeigeErgebnisse". I think i have to costumize this code... "ZeigeErgebnisse" will not work, if it stays like this...i have to adjust it to Mavliks code!?!
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
Thanks a lot to everybody of you!
Marco
Quoting - mavlik
Try this
[cpp]program testread
implicit none
INTEGER*4 I,J,TT
INTEGER*4 NDIS,NLEC,NCON
REAL*4 TIEFE(1000)
REAL*4 cC(1000)
REAL*4 Harte(1000)
REAL*4 RA(1000)
J = 0
NDIS = 1
OPEN (NDIS, FILE = 'ASCIIDATA.TXT')
DO WHILE (.NOT. EOF(1))
J = J + 1
READ (1, *) TIEFE(j), cC(J), Harte(j), RA(j)
WRITE(NCON,*) cC(j)
END DO
CLOSE(NDIS)
end program testread
[/cpp]
ASCIIDATA.txt:
0.000 0.706 63.445 5.125
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
0.016 0.707 63.417 5.189
0.032 0.709 63.388 5.254
0.048 0.711 63.360 5.319
0.064 0.713 63.331 5.385
0.080 0.714 63.302 5.450
0.096 0.716 63.274 5.516
0.112 0.717 63.245 5.582
0.128 0.719 63.216 5.648
0.144 0.721 63.187 5.713
0.160 0.722 63.159 5.779
Hi and thanks for your replies,
i tried to built the program similar to mavliks "testread", unfortunately it did not work. I think i made some mistakes because i tried to use my subroutine "ZeigeErgebnisse". Mavlik only used "write". Can somebody help me to integrate the "call ZeigeErgebnisse" SUBROUTINE Mavliks code?
Furthermore more i need some help with the subroutine "ZeigeErgebnisse". I think i have to costumize this code... "ZeigeErgebnisse" will not work, if it stays like this...i have to adjust it to Mavliks code!?!
SUBROUTINE ZeigeErgebnisse
USE ImportAsciiGeneral
IMPLICIT NONE
INTEGER ind
6000 FORMAT(F20.3,3X,F20.3)
DO ind = 1, dimV
WRITE(qwUErg, 6000) xV(ind), yV(ind)
END DO
RETURN
END
Thanks a lot to everybody of you!
Marco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
please attach the module Importasciigeneral, then we might be able to see what's wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - anthonyrichards
please attach the module Importasciigeneral, then we might be able to see what's wrong.
Hi, find attached to more Modules, which are required:
MODULE ImportAsciiGeneral
USE DFWIN
USE DFLIB
USE DFWINTY
USE ModuleImportAscii
USE DFLOGM
INCLUDE 'RESOURCE.FD'
LOGICAL :: lRet
INTEGER :: iRet, TextLen
INTEGER, PARAMETER :: qwUErg = 77
CHARACTER (LEN=80) :: Text
TYPE (T_OPENFILENAME) :: OF
END MODULE
MODULE ModuleImportAscii
INTEGER, PARAMETER :: dimV = 50, FUNIT = 7
Real*4 xV(dimV), yV(dimV)
CHARACTER (LEN=256) :: TxtFile = ''C
INTEGER, PARAMETER :: nFilter = 2
CHARACTER (LEN=*), PARAMETER :: FileFilter = 'Kohlenstofftiefenverlauf *.txt'C // '*.txt'C
CHARACTER (LEN=*), PARAMETER :: FileDefExt = 'Txt'C
END MODULE
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page