Simple questions of type YesNo and OKCancel can be presented to the user using

Simple questions of type yesno and okcancel can be

This preview shows page 11 - 12 out of 12 pages.

choices. Simple questions of type Yes/No and OK/Cancel can be presented to the user using the wxLua function wxMessageBox. For example: if (wx.wxMessageBox("Do you want to perform the operation?", "Question",wx.wxYES+wx.wxNO) == wx.wxNO) then myvar.result = 0; end wxLua also includes some functions for simple input dialog boxes, such as wxGetNumberFromUser, wxGetTextFromUser, wxGetSingleChoice, wxGetMultipleChoices. More complex dialog boxes require the wxDialog class. File name operations The myvar.srcfilename variable can be split into components as follows: local wxfn = wx.wxFileName(myvar.srcfilename); local fpath = wxfn:GetPath(wx.wxPATH_GET_VOLUME); local fname = wxfn:GetName(); local fext = wxfn:GetExt(); Troubleshooting Consequences of wrong variable names A common cause of script errors is that some variable name has been misspelled. In the Lua language, the names of fields in “structures” like myvar, src, or dest, are not defined anywhere in advance, but are implicitly created with nil values as soon as you refer to them. For example, if your intention is to make the assignment dest.description=src.background; but you accidentally write Background, then dest.description is assigned value nil. This causes an error because the program expects dest.description to be a string. If you misspell the variable name that you are assigning to, this will create a new variable. For example: dest.Description=src.background; does not give any error message, but the script does not work as desired because the intended variable dest.description remains unchanged. Also check that the value you assign is of the right type. Note in particular that all the parameter values in myvar.viewpar are strings. If you assign the value of a selection panel variable "department" to an integer field, you have to convert it to number, otherwise a type mismatch error occurs: dest.department = tonumber(myvar.viewpar["selpanel.department"]); -- correct dest.department = myvar.viewpar["selpanel.department"]; -- incorrect
Image of page 11
Anygraaf Neo System Configuration Guide Scripting Undefined wxLua functions If you get an error like attempt to call field 'wxXXX' (a nil value) the reason may be that you have tried to create an object from a wxWidgets class that is unknown to the version of wxLua that the program uses, and then you are calling a method on that object. If you get an error like wxLua: Unable to call an unknown method 'xxx' on a 'wxYYY' type. first check that the class and method names are correct. If they are, the reason for the error is that the particular method is not included in this version, even though the wxWidgets class is. The set of available functions may be extended in later program versions.
Image of page 12

You've reached the end of your free preview.

Want to read all 12 pages?

  • Summer '18

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes