View Full Version : Missing the obvious 'two parameters required' on 'end'????
jassing
03-09-2010, 11:20 AM
See attached.
I've moved the 3 line function around, the line # already is the 'end' statement.
I've even added a 2nd parameter to the function in the off chance it meant the declaration; no go...
what am I missing?
Imagine Programming
03-09-2010, 11:44 AM
Try checking all your code, the code inside that function, inside that object, inside pages. Because in this case usually the errorlevel (luastack) isn't really nice and returns the wrong line and/or event :p
I have had this issue many times myself and later found that the error was somewhere else, in the function being called for example.
jassing
03-09-2010, 11:47 AM
Thanks -- I've checked over all code, traced thru -- always the error is on "end".
Imagine Programming
03-09-2010, 01:03 PM
Thanks -- I've checked over all code, traced thru -- always the error is on "end".
Care to share the project? Perhaps I can help out.
jassing
03-09-2010, 01:13 PM
Thanks -- 10minutes ago I would have taken you up on it.
I started commenting things out to narrow down the bare essentials (not easy when there's 10K lines of code...)
Boiled it down to: (not actual code)
On select of a list box:
4: Input.SetText("inpMyInput",MyFunc("Form1") );
Global functions:
1101: function MyFunc( cText )
1102: -- do some processing
1103: end
The error should be "OnSelect Listbox1 -> Line 4, Expected text in 2nd parameter, got nil"
but instead the error is "OnSelect combox1 -> line 1103, two parameters expected"
Code in the OnSelect of the combox triggers onselect of the listbox...
My oversight for not having that function return the value it calculated, but that error was pretty off the wall; even for IR error reporting!
Imagine Programming
03-09-2010, 01:19 PM
Yeah some errorhandling needs some improval, and I know what you mean with
the 10k, my Object plugin currently as 90k code hehe. Yesterday when I added
the on the fly properties code, I had a bug somewhere and I couldn't find it...
the AMS runtime pointed me to an end keyword...
Anyhow, I'm glad you found the error :yes
RizlaUK
03-09-2010, 02:36 PM
when the error reporting is unreliable like that always check the indicated line number but in the global section, errors reported at a 'end' statement always come from a nested function call ..... this is why we need the debug lib!!!
and I know what you mean with
the 10k
yea, PX is at 57k lines and the editor is at 25k lines ...... bug track that bugger!!
D.A.M thing takes 10 minutes to compile the 2.3 MB runtime, but its got more power than E-ON :D
lol, when i take a break from the project, i return and spend 2 weeks finding my way in the labyrinth of code .... haven't even looked at in months tho :(
Josh, it takes a little more time, but iv learned to check my argument values when working with big projects, a simple nil value in a nested function can take hours to track down, all depends on how far down in the stack the function call was
a simple check can save hours of searching
if not cText then
error("cText is nil",1)
else
-- your code here
end
in future, if you come across this again, use 'pcall' on the function at the top of the stack, this way the error handler is direct from lua and bypass the AMS error handler, or if you want to handle the error yourself use 'xpcall'
the above has saved my ass a few times in my PX project, im sure it also applies to AMS (if those functions are available in 5.0.2 ??)
jassing
03-09-2010, 02:41 PM
You should use assert() instead of the if/then ERROR /else Your code/end simplier.... (just my $.02)
Imagine Programming
03-09-2010, 02:44 PM
the above has saved my ass a few times in my PX project, im sure it also applies to AMS (if those functions are available in 5.0.2 ??)
pcall with an function() and loadstring function returning a successboolean and the error (if any) will suffice I guess, lovely functions combined :p
function _surpress_errors(luastring)
local function eval(s)
return loadstring(s)();
end
return pcall(eval,luastring);
end
local bSuccess, szError = _surpress_errors("FuncDoesntExist();");
Dean, when you start picking up PX again, please let me know ^^ I've been putting of an encryption library to save it for PX, contains Whirlpool, sha1, sha256, xTea, xOr (several), AES Rijndael etc.
And ofcourse, for all the stuff you need me to do ^^ :yes
Sakuya
03-09-2010, 02:44 PM
You should use assert() instead of the if/then ERROR /else Your code/end simplier.... (just my $.02)
Seconded.
assert(type(argument1) == "table", "Argument 1 must be of type table.");
over
if (type(argument1) ~= "table") then
error("Argument 1 must be of type table");
end
Imagine Programming
03-09-2010, 02:56 PM
I prefer
if(type(var)~="table")then error("errormsg",2);end
I guess because I'm used to it now :p
RizlaUK
03-09-2010, 03:30 PM
assert!!
my misses says i assert myself to much as it is :D
assert(type(argument1) == "table", "Argument 1 must be of type table.");
much better, thanks :yes (im not rewriteing my code tho :p)
Centauri Soldier
03-09-2010, 03:56 PM
You know, the IRLua Plugin Helper Functions can be applied to more than just plugins. For big projects that code is invaluable and makes error tracking a breeze.
RizlaUK
03-09-2010, 04:13 PM
Dean, when you start picking up PX again, please let me know
sure thing, iv no immediate plans tho, just waiting for them to make a day 48 hours, then maybe i'll have time :D
You know, the IRLua Plugin Helper Functions can be applied to more than just plugins
sure can, for big projects it would be worth while, not that many people realise the importance of proper error checking tho unfortunately, iv even had a driver installer from Foxconn that was made with AMS (for E-Bot) and it had a few nil value errors, very amateur!!, the E-Bot is now sat in the corner of the laundry closet...what a waist of money that was!!
Imagine Programming
03-09-2010, 05:18 PM
sure thing, iv no immediate plans tho, just waiting for them to make a day 48 hours, then maybe i'll have time :D
Sure, take it easy, code doesn't run away :) Oh god 48 hour days would be nice indeed haha :p
sure can, for big projects it would be worth while, not that many people realise the importance of proper error checking tho unfortunately, iv even had a driver installer from Foxconn that was made with AMS (for E-Bot) and it had a few nil value errors, very amateur!!, the E-Bot is now sat in the corner of the laundry closet...what a waist of money that was!!
Even with perfect errorchecking errors can still emerge, so yes it's so important :p But in a case like this, a driver installer made with AMS, and you get nil value errors? XD Oh man, that's a funny failure :p
RizlaUK
03-10-2010, 03:59 AM
yeah, and those E-Bots were pulled of the shelves as quick as they were put on them, Maplin had them for about 2 weeks, i got mine 2 days after they went on sale, 2 weeks later i went to get one for someone else and i was told "product has been discontinued"!!
a bare bones PC in a box for £120, i guess you get what you pay for!!
Any one wanner buy a slightly used E-Bot?? :D
Imagine Programming
03-10-2010, 10:29 AM
Any one wanner buy a slightly used E-Bot?? :D
Hahaha :p After that info? I'd rather say no ^^ Dam those idiots:p
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.