Note that fileio has some limitations on the length of a path it will
read/write to. On modern versions of windows, this can easily cause
problems since default save paths look like:

C:\Documents and Settings\Kenneth Prat\My Documents\...

I swapped out fileio read/writes for the ones in the Pregex Xtra, which
has no such limitation.

Sample code:

---------------------------------------------------

on writeTextFile strval, strpath
  strval = replaceLineFeeds(strval)
  PRegEx_WriteEntireFile (strpath, [strval])
  if the platform starts "M" then baSetFileInfo(strpath, "TEXT", "ttxt")
end

on readTextFile strpath
  s = PRegEx_ReadEntireFile(strpath)
  if listp(s) then return stripLineFeeds(s[1])
  return ""
end

on stripLineFeeds strstr
  if strstr = VOID then return ""
  return replaceAll(strstr, RETURN, RETURN&numToChar(10))
end

on replaceLineFeeds strstr
  if strstr = VOID then return ""
  if the platform starts "W" then
    return replaceAll(strstr, RETURN&numToChar(10), RETURN)
  else
    return strstr
  end if
End

on replaceAll str, strReplace, strFind
  s = ""
  n1 = length(str)
  n2 = length(strFind)
  repeat while TRUE
    n = offset(strFind, str)
    if n then
      if n = 1 then 
        s = s & strReplace
      else
        s = s & str.char[1..n-1] & strReplace
      end if
      str = str.char[n+n2..n1] 
    else
      exit repeat
    end if
  end repeat
  s = s & str
  return s
end


[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to