-- Seq2.ex --------------------------------------------------------------------------------------
-- Sequence as text and as numbers
-- ----------------------------------------------------------------------------------------------
sequence AsText, AsNumbers -- declare
-- The next line will be interpreted by Euphoria to mean a sequence
-- of the ASCII code numbers of the characters in "This is text".
AsText = "This is text"
-- For the next line I just typed a sequence containing numbers
-- that are the ASCII codes of the characters in "This is text".
-- (you'd be crazy to create "This is text" in this way, except in a demo)
AsNumbers = {84,104,105,115,32,105,115,32,116,101,120,116}
if equal(AsText,AsNumbers) then
-- if we get to here, both sequences are the same, so tell the user:
puts(1,"Sequence AsText is the same as sequence AsNumbers.\n\n")
else
-- if we get to here, the sequences are not the same; tell user:
puts(1, "Sequences AsText and AsNumbers are not the same.\n\n")
end if
-- show the user what the sequences are when interpreted as text:
puts(1,"I'll verify this by printing each of them as if it was text:\n\n")
puts(1,"\t1. First, the sequence AsText:\n\n\t\t")
-- puts() now reproduces the sequence AsText as on-screen text
puts(1,AsText)
puts(1,"\n\n\t2. Next, the sequence AsNumbers:\n\n\t\t")
-- puts() now reproduces the sequence AsNumbers as on-screen text
puts(1,AsNumbers)
puts(1,"\n\n")
system("Pause",2) -- wait
-- End of listing -------------------------------------------------------------------------------
Conversion to HTML by PC2HTM.EXE