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,58 @@
' FB 1.05.0 Win64
Type DynamicVariable
As String name
As String value
End Type
Function FindVariableIndex(a() as DynamicVariable, v as String, nElements As Integer) As Integer
v = LCase(Trim(v))
For i As Integer = 1 To nElements
If a(i).name = v Then Return i
Next
Return 0
End Function
Dim As Integer n, index
Dim As String v
Cls
Do
Input "How many variables do you want to create (max 5) "; n
Loop Until n > 0 AndAlso n < 6
Dim a(1 To n) As DynamicVariable
Print
Print "OK, enter the variable names and their values, below"
For i As Integer = 1 to n
Print
Print " Variable"; i
Input " Name : ", a(i).name
a(i).name = LCase(Trim(a(i).name)) ' variable names are not case sensitive in FB
If i > 0 Then
index = FindVariableIndex(a(), a(i).name, i - 1)
If index > 0 Then
Print " Sorry, you've already created a variable of that name, try again"
i -= 1
Continue For
End If
End If
Input " Value : ", a(i).value
a(i).value = LCase(Trim(a(i).value))
Next
Print
Print "Press q to quit"
Do
Print
Input "Which variable do you want to inspect "; v
If v = "q" OrElse v = "Q" Then Exit Do
index = FindVariableIndex(a(), v, n)
If index = 0 Then
Print "Sorry there's no variable of that name, try again"
Else
Print "It's value is "; a(index).value
End If
Loop
End

View file

@ -0,0 +1,7 @@
local(thename = web_request->param('thename')->asString)
if(#thename->size) => {^
var(#thename = math_random)
var(#thename)
else
'<a href="?thename=xyz">Please give the variable a name!</a>'
^}

View file

@ -0,0 +1,7 @@
-- varName might contain a string that was entered by a user at runtime
-- A new global variable with a user-defined name can be created at runtime like this:
(the globals)[varName] = 23 -- or (the globals).setProp(varName, 23)
-- An new instance variable (object property) with a user-defined name can be created at runtime like this:
obj[varName] = 23 -- or obj.setProp(varName, 23)

View file

@ -0,0 +1,7 @@
: createVar(varname)
"tvar: " varname + eval ;
"myvar" createVar
12 myvar put
myvar at .

View file

@ -0,0 +1,2 @@
See "Enter the variable name: " give cName eval(cName+"=10")
See "The variable name = " + cName + " and the variable value = " + eval("return "+cName) + nl

View file

@ -0,0 +1,2 @@
Enter the variable name: test
The variable name = test and the variable value = 10

View file

@ -0,0 +1,10 @@
var name = read("Enter a variable name: ", String); # type in 'foo'
class DynamicVar(name, value) {
method init {
DynamicVar.def_method(name, ->(_) { value })
}
}
var v = DynamicVar(name, 42); # creates a dynamic variable
say v.foo; # retrieves the value