September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
14
Task/Read-entire-file/BASIC/read-entire-file-2.basic
Normal file
14
Task/Read-entire-file/BASIC/read-entire-file-2.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
10 rem load the entire contents of some text file as a single string variable.
|
||||
20 rem should avoid reading an entire file at once if the file is large
|
||||
30 rem ================================
|
||||
40 print chr$(14) : rem switch to upper+lowercase character set
|
||||
50 open 4,8,4,"data.txt,seq,read"
|
||||
60 n=0
|
||||
70 for i=0 to 1
|
||||
80 get#4,x$
|
||||
90 i=st and 64 : rem check for 'end-of-file'
|
||||
100 if i=0 then a$=a$+x$ : n=n+1
|
||||
110 if n=255 then i=1 : rem max string length is 255 only
|
||||
120 next
|
||||
130 close 4
|
||||
140 end
|
||||
1
Task/Read-entire-file/BaCon/read-entire-file-1.bacon
Normal file
1
Task/Read-entire-file/BaCon/read-entire-file-1.bacon
Normal file
|
|
@ -0,0 +1 @@
|
|||
content$ = LOAD$(filename$)
|
||||
3
Task/Read-entire-file/BaCon/read-entire-file-2.bacon
Normal file
3
Task/Read-entire-file/BaCon/read-entire-file-2.bacon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
binary = BLOAD("somefile.bin")
|
||||
PRINT "First two bytes are: ", PEEK(binary), " ", PEEK(binary+1)
|
||||
FREE binary
|
||||
6
Task/Read-entire-file/Gambas/read-entire-file.gambas
Normal file
6
Task/Read-entire-file/Gambas/read-entire-file.gambas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Public Sub Form_Open()
|
||||
Dim sFile As String
|
||||
|
||||
sFile = File.Load(User.home &/ "file.txt")
|
||||
|
||||
End
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
fun readText() {
|
||||
val string = File("unixdict.txt").readText(charset = Charsets.UTF_8)
|
||||
import java.io.File
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(File("unixdict.txt").readText(charset = Charsets.UTF_8))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
readFile(filename)
|
||||
3
Task/Read-entire-file/OoRexx/read-entire-file-1.rexx
Normal file
3
Task/Read-entire-file/OoRexx/read-entire-file-1.rexx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
file = 'c:\test.txt'
|
||||
myStream = .stream~new(file)
|
||||
myString = myStream~charIn(,myStream~chars)
|
||||
7
Task/Read-entire-file/OoRexx/read-entire-file-2.rexx
Normal file
7
Task/Read-entire-file/OoRexx/read-entire-file-2.rexx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
file = 'c:\test.txt'
|
||||
myStream = .stream~new(file)
|
||||
if mystream~open('read') = 'READY:'
|
||||
then do
|
||||
myString = myStream~charIn(,myStream~chars)
|
||||
myStream~close
|
||||
end
|
||||
9
Task/Read-entire-file/OoRexx/read-entire-file-3.rexx
Normal file
9
Task/Read-entire-file/OoRexx/read-entire-file-3.rexx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
address hostemu 'execio * diskr "./st.in" (finis stem in.'
|
||||
Say in.0 'lines in file st.in'
|
||||
v=''
|
||||
Do i=1 To in.0
|
||||
Say i '>'in.i'<'
|
||||
v=v||in.i
|
||||
End
|
||||
say 'v='v
|
||||
::requires "hostemu" LIBRARY
|
||||
1
Task/Read-entire-file/SPL/read-entire-file.spl
Normal file
1
Task/Read-entire-file/SPL/read-entire-file.spl
Normal file
|
|
@ -0,0 +1 @@
|
|||
text = #.readtext("filename.txt")
|
||||
8
Task/Read-entire-file/Stata/read-entire-file.stata
Normal file
8
Task/Read-entire-file/Stata/read-entire-file.stata
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
mata
|
||||
f = fopen("somedata.txt", "r")
|
||||
fseek(f, 0, 1)
|
||||
n = ftell(f)
|
||||
fseek(f, 0, -1)
|
||||
s = fread(f, n)
|
||||
fclose(f)
|
||||
end
|
||||
1
Task/Read-entire-file/Zkl/read-entire-file.zkl
Normal file
1
Task/Read-entire-file/Zkl/read-entire-file.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
data := File("foo.txt","r").read()
|
||||
Loading…
Add table
Add a link
Reference in a new issue