RosettaCodeData/Task/Dynamic-variable-names/Phix/dynamic-variable-names.phix

17 lines
518 B
Plaintext

constant globals = new_dict()
while 1 do
string name = prompt_string("Enter name or press Enter to quit:")
if length(name)=0 then exit end if
integer k = getd_index(name,globals)
if k=0 then
string data = prompt_string("No such name, enter a value:")
setd(name,data,globals)
else
string data = prompt_string(sprintf("Already exists, new value[%s]:",{getd(name,globals)}))
if length(data) then
setd(name,data,globals)
end if
end if
end while