?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. -- Set Text Strings
  2.  
  3. -- See the main docs for information on text strings
  4.  
  5. -- String 0 is not shown in the map (blank)
  6.  
  7. function main()
  8.  
  9.  if mappy.msgBox("Set Text Strings", "Load text strings into a FMP map. Select a text file, each line will be a string.\n\nContinue?", mappy.MMB_OKCANCEL, mappy.MMB_ICONQUESTION ) == mappy.MMB_OK then
  10.  
  11.   local isok,asname = mappy.fileRequester (".", "Textfile (*.txt)", "*.txt", mappy.MMB_OPEN)
  12.   if isok == mappy.MMB_OK then
  13.  
  14.    local i = 0
  15.    for line in io.lines (asname) do
  16.     mappy.setTextString (i, line)
  17.     i = i + 1
  18.    end
  19.   end
  20.  
  21.  
  22. -- replace an existing string
  23. -- mappy.setTextString (3, "Replaced string number 3")
  24.  
  25. -- delete string (only works on last string, send "-del")
  26. -- mappy.setTextString (mappy.getValue(mappy.NUMTEXTSTR)-1, "-del")
  27.  
  28.   local isok,index = mappy.doDialogue ("Set Text Strings", "Which Block/Object user field?", "1", mappy.MMB_DIALOGUE1)
  29.   index = tonumber (index)
  30.   mappy.setValue(mappy.STRBLKUSER, index)
  31.   mappy.setValue(mappy.STROBJUSER, index)
  32.  end
  33. end
  34.  
  35. test, errormsg = pcall( main )
  36. if not test then
  37.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  38. end
  39.  
  40.