Read a configuration file: Difference between revisions

No edit summary
Line 3,259:
 
<syntaxhighlight lang="m2000 interpreter">
module check(a$, id as list){
Document Export$
nl$={
Line 3,286:
end if
a$=trim$(rightpart$(a$," "))
// optional = removed
if len(a$)=0 then // we have a boolean
if left$(a$,1)="=" then a$=trim$(mid$(a$,2))
Export$=b$+" = "+if$(NotUsed->"false", "true")+nl$
// if not exist ignore it
else.if instr(a$,",")>0 then // multiple value
if exist(id,ucase$(b$)) then
local a$()
if len(a$)=0 then // we have a boolean
a$()=piece$(a$,",")
Export$=b$+" = "+if$(NotUsed->"false", "true")+nl$
for i=0 to len(a$())-1
else.if instr(a$,",")>0 then // multiple value
Export$=format$("{0}({1}) = {2}",b$,i+1, trim$(a$(i)))+nl$
next local a$()
a$()=piece$(a$,",")
else
Export$=b$+" for i=0 "+to len(a$+nl$())-1
Export$=format$("{0}({1}) = {2}",b$,i+1, trim$(a$(i)))+nl$
next
else
Export$=b$+" = "+a$+nl$
end if
end if
End Sub
}
valid=list:="FULLNAME", "FAVOURITEFRUIT", "NEEDSPEELING", "SEEDSREMOVED", "OTHERFAMILY"
binary{
UEsDBBQAAAgIAO8FflU2rdfqSAIAANQDAAARAAAAY29uZmlndXJhdGlvbi50eHRT
Line 3,324 ⟶ 3,330:
close #f
document b$ : Load.doc b$, "configuration.txt", 1033
check b$, valid
else
check chr$(eval$(buf)), valid
end if
</syntaxhighlight>
Line 3,337 ⟶ 3,343:
OTHERFAMILY(2) = Harry Barber
</pre>
 
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
404

edits