Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863

    Missing the obvious 'two parameters required' on 'end'????

    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?

  2. #2
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    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

    I have had this issue many times myself and later found that the error was somewhere else, in the function being called for example.
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  3. #3
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Thanks -- I've checked over all code, traced thru -- always the error is on "end".


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  4. #4
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by jassing View Post
    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.
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  5. #5
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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!


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  6. #6
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    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
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  7. #7
    Join Date
    May 2006
    Posts
    5,380
    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

    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
    Code:
    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 ??)
    Open your eyes to Narcissism, Don't let her destroy your life!!

  8. #8
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    You should use assert() instead of the if/then ERROR /else Your code/end simplier.... (just my $.02)


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  9. #9
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by RizlaUK View Post
    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

    Code:
    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 ^^
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  10. #10
    Join Date
    Oct 2009
    Location
    Merton, United Kingdom
    Posts
    684
    Quote Originally Posted by jassing View Post
    You should use assert() instead of the if/then ERROR /else Your code/end simplier.... (just my $.02)
    Seconded.

    Code:
    assert(type(argument1) == "table", "Argument 1 must be of type table.");
    over

    Code:
    if (type(argument1) ~= "table") then
        error("Argument 1 must be of type table");
    end

  11. #11
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    I prefer
    Code:
    if(type(var)~="table")then error("errormsg",2);end
    I guess because I'm used to it now
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

  12. #12
    Join Date
    May 2006
    Posts
    5,380
    assert!!

    my misses says i assert myself to much as it is

    Code:
    assert(type(argument1) == "table", "Argument 1 must be of type table.");
    much better, thanks (im not rewriteing my code tho )
    Open your eyes to Narcissism, Don't let her destroy your life!!

  13. #13
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    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.
    Action Plugins
    AllOn | Box | Class | Code | Cursor | DXML | Error | Frames | GlobalPaths | Group | INIPlus |KeyBind | KeyLock | MathEx | Menu | Name | Project | Resize | StatusBar
    Download

  14. #14
    Join Date
    May 2006
    Posts
    5,380
    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

    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!!
    Open your eyes to Narcissism, Don't let her destroy your life!!

  15. #15
    Join Date
    Apr 2007
    Location
    Raalte, OV, Netherlands
    Posts
    3,287
    Quote Originally Posted by RizlaUK View Post
    sure thing, iv no immediate plans tho, just waiting for them to make a day 48 hours, then maybe i'll have time
    Sure, take it easy, code doesn't run away Oh god 48 hour days would be nice indeed haha

    Quote Originally Posted by RizlaUK View Post
    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 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
    Bas Groothedde
    Imagine Programming :: Blog :: Familiar people here

    My AMS Plugins:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts