?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. -- Set Text Strings
  2.  
  3. -- See the main docs for information on text strings
  4. -- For this example, keep the strings in a table, you could parse a textfile
  5.  
  6. -- String 0 is not shown in the map (blank)
  7. textstrings = {
  8. "None set",
  9. "Text string 1",
  10. "Text string 2",
  11. "Text string 3",
  12. "Text string 4",
  13. "Text string 5",
  14. "Text string 6",
  15. "Text string 7, the last one"
  16. }
  17.  
  18. function main()
  19.  
  20.  if mappy.msgBox("Set Text Strings", "An example of how to load text strings into a FMP map, see the 'Set Text Strings.lua' source for more info.\n\nContinue?", mappy.MMB_OKCANCEL, mappy.MMB_ICONQUESTION ) == mappy.MMB_OK then
  21.  
  22. -- load the strings in order
  23.   for i = 1,table.getn(textstrings) do
  24.    mappy.setTextString (i-1, textstrings[i])
  25.   end
  26.  
  27. -- replace an existing string
  28. -- mappy.setTextString (3, "Replaced string number 3")
  29.  
  30. -- delete string (only works on last string, send "-del")
  31. -- mappy.setTextString (mappy.getValue(mappy.NUMTEXTSTR)-1, "-del")
  32.  
  33.   local isok,index = mappy.doDialogue ("Set Text Strings", "Which Block/Object user field?", "1", mappy.MMB_DIALOGUE1)
  34.   index = tonumber (index)
  35.   mappy.setValue(mappy.STRBLKUSER, index)
  36.   mappy.setValue(mappy.STROBJUSER, index)
  37.  end
  38. end
  39.  
  40. test, errormsg = pcall( main )
  41. if not test then
  42.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  43. end
  44.  
  45.