on MakeListFromText myText,myDelim,firstLine,wichWay,maxChars
  Global gMaxCount,gFirstTextList
  
  if myText <> "" then
    set myMainList       = []
     set myCount          = GetParaCount(myText,myDelim,firstLine)
    set gFirstTextList = []
    
    if myCount > 0 then
      if firstLine > 1 then                                         
        repeat with x = 1 to (firstLine - 1)
          add(gFirstTextList,line x of myText)
        end repeat
      end if
      
      repeat with x = 1 to myCount                                  
        add(myMainList,[:])
      end repeat
      
      repeat with x = firstLine to the number of lines in myText    
        set myLine = line x of myText
        repeat with y = 1 to myCount                                
          set myFirstText = GetStringFrom(myLine,myDelim,TRUE)    
          if myFirstText <> "" then
            if wichWay = 1 then
              addProp(getAt(myMainList,y),Substring(GetStringFrom(myLine,myDelim,TRUE),1,maxChars),x)
            else
              addProp(getAt(myMainList,y),x,Substring(GetStringFrom(myLine,myDelim,TRUE),1,maxChars))
            end if
          end if
          set myLine = GetStringTo(myLine,myDelim,TRUE)
        end repeat
      end repeat
      
      sort(getAt(myMainList,1))                                     
    end if
    
    set gMaxCount = count(getAt(myMainList,1)) + (firstLine - 1)
    
    return myMainList
  else
    return []
  end if
end  MakeListFromText


on KillUnixLF myText
  if myText <> "" then
    set myNewText = ""
    
    repeat with x = 1 to the number of chars in myText
      if char x of myText <> NumToChar(10) then
        set myNewText = myNewText & char x of myText
      else
        if x > 1 then
          if char (x - 1) of myText <> NumToChar(13) then
            set myNewText = myNewText & RETURN
          end if
        else
          set myNewText = myNewText & RETURN
        end if
      end if
    end repeat
    
    return myNewText
  else
    return ""
  end if
end KillUnixLF


on Substring myString,fromChar,toChar
  if myString <> "" then
    return char fromChar to toChar of myString
  else
    return ""
  end if
end Substring


on GetParaCount myText,myDelim,firstLine
  if myText <> "" then
    set myCount = 1
    set myFlag = TRUE
    
    set myLine = line firstLine of myText
    
    repeat while myFlag
      set myNewText = GetStringTo(myLine,myDelim,FALSE)
      if myNewText <> "" then
        set myLine  = myNewText
        set myCount = myCount + 1
      else
        set myFlag  = FALSE
      end if
    end repeat
    
    return myCount
  else
    return 0
  end if
end GetParaCount


on GetStringFrom myLine,myDelim,retFlag
  if myLine <> "" then
    if offset(myDelim, myLine) > 0 then
      return char 1 to (offset(myDelim, myLine) - 1) of myLine
    else
      if retFlag then
        return myLine
      else
        return ""
      end if
    end if
  else
    return ""
  end if
end GetStringFrom


on GetStringTo myLine,myDelim,retFlag
  if myLine <> "" then
    if offset(myDelim, myLine) > 0 then
      return char (offset(myDelim, myLine) + 1) to (length(myLine)) of myLine
    else
      if retFlag then
        return myLine
      else
        return ""
      end if
    end if
  else
    return ""
  end if
end GetStringTo


on MakeNull oldValue,noOfChars
  set oldStr = string(oldValue)
  
  set newStr = oldStr
  
  if length(oldStr) < noOfChars then
    repeat with x = 1 to (noOfChars - length(oldStr))
      set newStr = "0" & newStr
    end repeat
  end if
  
  return newStr
end MakeNull


on GetBrowserName
  Global gLimit
  set oldDel = the itemDelimiter
  set the itemDelimiter = gLimit
  set myBrowser = the last item of browserName()
  set the itemDelimiter = oldDel
  
  return myBrowser
end GetBrowserName
