PtokaX forum

Development Section => Your Developing Problems => Topic started by: kepp on 15 November, 2004, 22:58:46

Title: Function ByRef
Post by: kepp on 15 November, 2004, 22:58:46
I have a little problem

I would like to load a textfile into Settings.Main.General.Hubad       table

and this code works just great to do so

function LoadTextFile(file)
   local sMessage = "";
   readfrom(file)
   while 1 do
      local line = read();
      if line == nil then break
      else
      sMessage = sMessage..line.."\r\n";
      end
   end
   Settings.Main.General.Hubad = sMessage;
end

but i would like this to work for other things aswell
so i edited it a little :

function LoadTextFile(obj,file)
   local sMessage = "";
   readfrom(file)
   while 1 do
      local line = read();
      if line == nil then break
      else
      sMessage = sMessage..line.."\r\n";
      end
   end
   obj = sMessage;
end

when i call this function it looks like : LoadTextFile(Settings.Main.General.Hubad,"File")

BUT, dosen't work, Anybody knows why or what im doing wrong??
Title:
Post by: plop on 16 November, 2004, 01:45:24
try like this.
function LoadTextFile(file)
   local sMessage = ""
   readfrom(file)
   while 1 do
      local line = read()
      if line == nil then break
      else
  sMessage = sMessage..line.."\r\n"
      end
   end
   readfrom()
   return sMessage
end

Settings.Main.General.Hubad = LoadTextFile("File")

plop