Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,105 @@
' FB 1.05.0 Win64
Type ConfigData
favouriteFruit As String
needsPeeling As Boolean
seedsRemoved As Boolean
numberOfBananas As UInteger
numberOfStrawberries As UInteger
End Type
Sub updateConfigData(fileName As String, cData As ConfigData)
Dim fileNum As Integer = FreeFile
Open fileName For Input As #fileNum
If err > 0 Then
Print "File could not be opened"
Sleep
End
End If
Dim tempFileName As String = "temp_" + fileName
Dim fileNum2 As Integer = FreeFile
Open tempFileName For Output As #fileNum2
Dim As Boolean hadFruit, hadPeeling, hadSeeds, hadBananas, hadStrawberries '' all false by default
Dim As String ln
While Not Eof(fileNum)
Line Input #fileNum, ln
If ln = "" OrElse Left(ln, 1) = "#" Then
Print #fileNum2, ln
Continue While
End If
ln = Trim(LTrim(ln, ";"), Any !" \t")
If ln = "" Then Continue While
If UCase(Left(ln, 14)) = "FAVOURITEFRUIT" Then
If hadFruit Then Continue While
hadFruit = True
Print #fileNum2, "FAVOURITEFRUIT " + cData.favouriteFruit
ElseIf UCase(Left(ln, 12)) = "NEEDSPEELING" Then
If hadPeeling Then Continue While
hadPeeling = True
If cData.needsPeeling Then
Print #fileNum2, "NEEDSPEELING"
Else
Print #fileNum2, "; NEEDSPEELING"
End If
ElseIf UCase(Left(ln, 12)) = "SEEDSREMOVED" Then
If hadSeeds Then Continue While
hadSeeds = True
If cData.seedsRemoved Then
Print #fileNum2, "SEEDSREMOVED"
Else
Print #fileNum2, "; SEEDSREMOVED"
End If
ElseIf UCase(Left(ln, 15)) = "NUMBEROFBANANAS" Then
If hadBananas Then Continue While
hadBananas = True
Print #fileNum2, "NUMBEROFBANANAS " + Str(cData.numberOfBananas)
ElseIf UCase(Left(ln, 20)) = "NUMBEROFSTRAWBERRIES" Then
If hadStrawberries Then Continue While
hadStrawberries = True
Print #fileNum2, "NUMBEROFSTRAWBERRIES " + Str(cData.numberOfStrawBerries)
End If
Wend
If Not hadFruit Then
Print #fileNum2, "FAVOURITEFRUIT " + cData.favouriteFruit
End If
If Not hadPeeling Then
If cData.needsPeeling Then
Print #fileNum2, "NEEDSPEELING"
Else
Print #fileNum2, "; NEEDSPEELING"
End If
End If
If Not hadSeeds Then
If cData.seedsRemoved Then
Print #fileNum2, "SEEDSREMOVED"
Else
Print #fileNum2, "; SEEDSREMOVED"
End If
End If
If Not hadBananas Then
Print #fileNum2, "NUMBEROFBANANAS " + Str(cData.numberOfBananas)
End If
If Not hadStrawberries Then
Print #fileNum2, "NUMBEROFSTRAWBERRIES " + Str(cData.numberOfStrawBerries)
End If
Close #fileNum : Close #fileNum2
Kill(fileName)
Name (tempFileName fileName)
End Sub
Dim fileName As String = "config2.txt"
Dim cData As ConfigData
With cData
.favouriteFruit = "banana"
.needsPeeling = False
.seedsRemoved = True
.numberOfBananas = 1024
.numberOfStrawberries = 62000
End With
updateConfigData fileName, cData
Print
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1,99 @@
#!/usr/bin/lasso9
define config => type {
data public configtxt, public path
public oncreate(
path::string = 'testing/configuration.txt'
) => {
.configtxt = file(#path) -> readstring
.path = #path
}
public get(term::string) => {
.clean
local(
regexp = regexp(-find = `(?m)^` + #term + `($|\s*=\s*|\s+)(.*)$`, -input = .configtxt, -ignorecase),
result
)
while(#regexp -> find) => {
#result = (#regexp -> groupcount > 1 ? (#regexp -> matchString(2) -> trim& || true))
if(#result -> asstring >> ',') => {
#result = #result -> split(',')
#result -> foreach => {#1 -> trim}
}
return #result
}
return false
}
public set(term::string, value) => {
if(#value === false) => {
.disable(#term)
return
}
.enable(#term)
if(#value -> isanyof(::string, ::integer, ::decimal)) => {
.configtxt = regexp(-find = `(?m)^(` + #term + `) ?(.*?)$`, -replace = `$1 ` + #value, -input = .configtxt, -ignorecase) -> replaceall
}
}
public disable(term::string) => {
.clean
local(regexp = regexp(-find = `(?m)^(` + #term + `)`, -replace = `; $1`, -input = .configtxt, -ignorecase))
.configtxt = #regexp -> replaceall
}
public enable(term::string, -comment::string = '# Added ' + date) => {
.clean
local(regexp = regexp(-find = `(?m)^(; )?(` + #term + `)`, -replace = `$2`, -input = .configtxt, -ignorecase))
if(#regexp -> find) => {
.configtxt = #regexp -> replaceall
else
.configtxt -> append('\n' + (not #comment -> beginswith('#') ? '# ') +
#comment + '\n' +
string_uppercase(#term) + '\n'
)
}
}
public write => {
local(config = file(.path))
#config -> opentruncate
#config -> dowithclose => {
#config -> writestring(.configtxt)
}
}
public clean => {
local(
cleaned = array,
regexp = regexp(-find = `^(;+)\W*$`)
)
with line in .configtxt -> split('\n') do {
#line -> trim
#regexp -> input = #line
if(#line -> beginswith('#') or #line == '') => {
#cleaned -> insert(#line)
else(not (#regexp -> find))
if(#line -> beginswith(';')) => {
#line -> replace(regexp(`^;+ *`), `; `)
else
#line -> replace(regexp(`^(.*?) +(.*?)`), `$1 $2`)
}
#line -> replace(regexp(`\t`))
#cleaned -> insert(#line)
}
}
.configtxt = #cleaned -> join('\n')
}
}

View file

@ -0,0 +1,15 @@
local(
config = config,
)
stdoutnl(#config -> get('FAVOURITEFRUIT'))
stdoutnl(#config -> get('SEEDSREMOVED'))
stdoutnl(#config -> get('NUMBEROFBANANAS'))
#config -> enable('seedsremoved')
#config -> enable('PARAMWITHCOMMENT', -comment = 'This param was added to demonstrate the possibility to also have comments associated with it')
#config -> disable('needspeeling')
#config -> set('numberofstrawberries', 62000)
#config -> set('numberofbananas', 1024)
#config -> write