I wonder if anyone can help... The problem...I have a large text file which I would like to place in the clipboard (to use elsewhere) using FTN95. The file can contain up to 1,000,000 lines and up to 100 columns (can be as big as 60 MB). I've knocked up a piece of code to do this but it is slow. Methinks it's due to all the Character string manipulations and concatenation! As an example, a text file containing 24,000 rows and 12 columns (all numbers) took about 40 seconds on my PC (i7 processor). I've concluded there must be a quicker way of doing this. The code (a bit on the rough side) is shown and it works, albeit take a coffee break waiting for it to complete!! The text file numbers are TAB separated. Any help most welcome. Thanks. From Notquitenewton.
IMPLICIT NONE
INCLUDE <windows.ins> , nolist
CHARACTER (len=5000) :: str
CHARACTER (len=5000050) :: str1, buff
INTEGER :: j, i, k
C Open text file (tab separated numbers) with up to 100 cols. C and 1,000,000 rows. The file tested has 12 columns and 24,000 C rows. This routine took about 40 seconds (i7 processor!!) to C concatenate all rows into 1 string (this took the time) before C copying to the clipboard. Compiler Siverfrost FTN95 V8.70.
OPEN(FILE='C:\\PCModfit V7.1\\Results\\supout.txt',UNIT=45)
str1 = \' \'
50 READ(45,'(A)',END=100)str j = len_trim(str) i = len_trim(str1) buff = str1(1:i)//str(1:j) j = j + i C Add CR/LF to end of each line str1 = buff(1:j)//char(13)//char(10) GOTO 50
100 j = len_trim(str1) buff = str1(1:j)//char(0) j = j+1 CLOSE(UNIT=45)
C Send string to clipboard and get size. i = copy_to_clipboard@(buff(1:j),j,cf_text) j = sizeof_clipboard_text@() k = WINIO@('%fn[Courier New]%bf%ts&',1.5D0) k = WINIO@('%ca[Run complete]Finished! Size %rd'// & '%nl%nl%cn%5BT[OK]',j) END