Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Open "input.txt" For Input As #1
|
||||
Dim line_ As String
|
||||
Dim count As Integer = 0
|
||||
While Not Eof(1)
|
||||
Line Input #1, line_ '' read each line
|
||||
count += 1
|
||||
If count = 7 Then
|
||||
line_ = Trim(line_, Any !" \t") '' remove any leading or trailing spaces or tabs
|
||||
If line_ = "" Then
|
||||
Print "The 7th line is empty"
|
||||
Else
|
||||
Print "The 7th line is : "; line_
|
||||
End If
|
||||
Exit While
|
||||
End If
|
||||
Wend
|
||||
If count < 7 Then
|
||||
Print "There are only"; count; " lines in the file"
|
||||
End If
|
||||
Close #1
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
dim as long i : i = 1
|
||||
dim as Str255 s, lineSeven
|
||||
dim as CFURLRef url
|
||||
|
||||
if ( files$( _CFURLRefOpen, "TEXT", "Select text file", @url ) )
|
||||
open "I", 2, @url
|
||||
while ( not eof(2) )
|
||||
line input #2, s
|
||||
if ( i == 7 )
|
||||
lineSeven = s
|
||||
end if
|
||||
i++
|
||||
wend
|
||||
close 2
|
||||
end if
|
||||
|
||||
if ( lineSeven[0] )
|
||||
print lineSeven
|
||||
else
|
||||
print "File did not contain seven lines, or line was empty."
|
||||
end if
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
local(f) = file('unixdict.txt')
|
||||
handle => { #f->close }
|
||||
local(this_line = string,line = 0)
|
||||
#f->forEachLine => {
|
||||
#line++
|
||||
#line == 7 ? #this_line = #1
|
||||
#line == 7 ? loop_abort
|
||||
}
|
||||
#this_line // 6th, which is the 7th line in the file
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
iter = io.lines 'test.txt'
|
||||
for i=0, 5
|
||||
error 'Not 7 lines in file' if not iter!
|
||||
|
||||
print iter!
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
var
|
||||
line: TaintedString
|
||||
f = open("test.txt", fmRead)
|
||||
|
||||
for x in 0 .. 6:
|
||||
try:
|
||||
line = readLine f
|
||||
except EIO:
|
||||
echo "Not 7 lines in file"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fp = fopen("C:\Ring\ReadMe.txt","r")
|
||||
n = 0
|
||||
|
||||
r = ""
|
||||
while isstring(r)
|
||||
while n < 8
|
||||
r = fgetc(fp)
|
||||
if r = char(10) n++ see nl
|
||||
else see r ok
|
||||
end
|
||||
end
|
||||
fclose(fp)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
func getNthLine(filename, n) {
|
||||
var file = File.new(filename);
|
||||
file.open_r.each { |line|
|
||||
Num($.) == n && return line;
|
||||
}
|
||||
warn "file #{file} does not have #{n} lines, only #{$.}\n";
|
||||
return nil;
|
||||
}
|
||||
|
||||
var line = getNthLine("/etc/passwd", 7);
|
||||
print line if defined line;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
decl string<> lines
|
||||
decl file f
|
||||
f.open "filename.txt"
|
||||
set lines (f.readlines)
|
||||
f.close
|
||||
|
||||
if (< (size lines) 7)
|
||||
out "the file has less than seven lines" endl console
|
||||
stop
|
||||
end if
|
||||
|
||||
out "the seventh line in the file is:" endl endl console
|
||||
out lines<6> endl console
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Input - a line number to read, counting from 1
|
||||
# Output - a stream with 0 or 1 items
|
||||
def read_line:
|
||||
. as $in
|
||||
| label $top
|
||||
| foreach inputs as $line
|
||||
(0; .+1; if . == $in then $line, break $top else empty end) ;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$line | tonumber
|
||||
| if . > 0 then read_line
|
||||
else "$line (\(.)) should be a non-negative integer"
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ jq -n -r 'range(0;20) | tostring' | jq --arg line 10 -n -R -r -f Read_a_specific_line_from_a_file.jq
|
||||
9
|
||||
Loading…
Add table
Add a link
Reference in a new issue