Hi David,
I am a bit confused here, why couldn't you simply use "item x of whatever" instead of named variables? Since those "names" do not convey what they are holding...
In any case, you could create those variables in your script like this:
set valueFile to ((path to desktop folder) as text) & "values.txt"
set myValues to read file valueFile using delimiter {return}
try
set varName1 to item 1 of myValues
end try
try
set varName2 to item 2 of myValues
end try
try
set varName3 to item 3 of myValues
end try
try
set varName4 to item 4 of myValues
end try
try
set varName5 to item 5 of myValues
end try
...
You just need to put enough "try blocks" to deal with whatever text file you wish to pass to the script. (btw those try block can easily be created with a script if there's too many of them to create.)
But, I would rather use the more simple way of just addressing the "values" by their item number :
set valueFile to ((path to desktop folder) as text) & "values.txt"
-- Contents of values.txt:
-- 2019/01/28
-- Text Value1
-- 100
-- true
-- 2,5
set myValues to read file valueFile using delimiter {return}
set myVars to {}
repeat with i from 1 to count of myValues
set end of myVars to my detectVarType(item i of myValues)
end repeat
set resultText to ""
repeat with i from 1 to count of myVars
set myVar to item i of myVars
set resultText to resultText & i & ": [" & class of myVar & "] -> " & myVar & return
end repeat
display dialog resultText
on detectVarType(aValue)
if aValue is "true" then
set aValue to true
else if aValue is "false" then
set aValue to false
end if
try
set aValue to aValue as real
if aValue mod 10 = 0 then
set aValue to aValue as integer
end if
end try
try
set aValue to date aValue
end try
return aValue
end detectVarType
As a bonus, I added a handler that determine the type of variable you are attempting to read.
HTH
Michel