Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -1,28 +1,3 @@
|
|||
{{omit From|ACL2}}
|
||||
{{omit From|Ada}}
|
||||
{{omit from|AmigaE}}
|
||||
{{omit from|AWK}}
|
||||
{{omit from|ALGOL 68}}
|
||||
{{omit from|C}}
|
||||
{{omit from|C++}}
|
||||
{{omit from|D}}
|
||||
{{omit from|Delphi}}
|
||||
{{omit from|Fortran}}
|
||||
{{omit from|Free Pascal}}
|
||||
{{omit from|GUISS}}
|
||||
{{omit from|Java}}
|
||||
{{omit from|Lily}}
|
||||
{{omit from|Locomotive Basic}}
|
||||
{{omit from|Metafont}}
|
||||
{{omit from|NetRexx}}
|
||||
{{omit from|Octave}}
|
||||
{{omit from|Pascal}}
|
||||
{{omit from|PureBasic}}
|
||||
{{omit from|Rust}}
|
||||
{{omit from|Swift}}
|
||||
{{omit from|zkl}}
|
||||
{{omit from|ZX Spectrum Basic}}
|
||||
|
||||
;Task:
|
||||
Create a variable with a user-defined name.
|
||||
|
||||
|
|
|
|||
36
Task/Dynamic-variable-names/AWK/dynamic-variable-names.awk
Normal file
36
Task/Dynamic-variable-names/AWK/dynamic-variable-names.awk
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# syntax: GAWK -f DYNAMIC_VARIABLE_NAMES.AWK
|
||||
# Variables created in GAWK's internal SYMTAB (symbol table) can only be accessed via SYMTAB[name]
|
||||
BEGIN {
|
||||
PROCINFO["sorted_in"] = "@ind_str_asc"
|
||||
show_symbol_table()
|
||||
while (1) {
|
||||
printf("enter variable name? ")
|
||||
getline v_name
|
||||
if (v_name in SYMTAB) {
|
||||
printf("name already exists with a value of '%s'\n",SYMTAB[v_name])
|
||||
continue
|
||||
}
|
||||
if (v_name ~ /^$/) {
|
||||
printf("name is null\n")
|
||||
continue
|
||||
}
|
||||
if (v_name !~ /^[A-Za-z][A-Za-z0-9_]*$/) {
|
||||
printf("name illegally constructed\n")
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
printf("enter value? ")
|
||||
getline v_value
|
||||
SYMTAB[v_name] = v_value
|
||||
printf("variable '%s' has been created and assigned the value '%s'\n\n",v_name,v_value)
|
||||
show_symbol_table()
|
||||
exit(0)
|
||||
}
|
||||
function show_symbol_table( count,i) {
|
||||
for (i in SYMTAB) {
|
||||
printf("%s ",i)
|
||||
if (isarray(SYMTAB[i])) { count++ }
|
||||
}
|
||||
printf("\nsymbol table contains %d names of which %d are arrays\n\n",length(SYMTAB),count)
|
||||
}
|
||||
|
|
@ -12,10 +12,10 @@ class TestClass
|
|||
|
||||
closure()
|
||||
{
|
||||
auto varRef := new MessageName(console.write:"Enter the variable name:".readLine());
|
||||
mixin varRef(theVariables).prop := 42;
|
||||
auto prop := new MessageName(console.write:"Enter the variable name:".readLine());
|
||||
(prop.setPropertyMessage())(theVariables,42);
|
||||
|
||||
console.printLine(varRef.Printable,"=",mixin varRef(theVariables).get).readChar()
|
||||
console.printLine(prop.Printable,"=",(prop.getPropertyMessage())(theVariables)).readChar()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
:newVariable ("-) s:get var ;
|
||||
|
||||
newVariable: foo
|
||||
Loading…
Add table
Add a link
Reference in a new issue