Script: Make DialogEx return any value. (table, function, string, thread, ...)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Sakuya
    No longer a forum member
    • Oct 2009
    • 682

    Script: Make DialogEx return any value. (table, function, string, thread, ...)

    Here's a little script that you may find incredibly useful. (Requires AMS 7.5)

    Code:
    DialogEx._Show = DialogEx.Show;
    DialogEx._Close = DialogEx.Close;
    
    function DialogEx.Show(szDialogName, blParentCoordinates, intX, intY)
    	assert(type(szDialogName) == "string", "Argument 1 must be of type string.");
    	
    	if not (blParentCoordinates) then
    		blParentCoordinates = false;
    	end
    	
    	local modalReturn = DialogEx._Show(szDialogName, blParentCoordinates, intX, intY);
    	
    	if (modalReturn == 1001) then
    		local vtReturn = DialogEx._Return;
    		DialogEx._Return = nil;
    		return vtReturn;
    	else
    		return modalReturn;
    	end
    end
    
    function DialogEx.Close(vtValue)
    	DialogEx._Return = vtValue;
    	DialogEx._Close(1001);
    end
    This script will allow you to use DialogEx.Close with any type of argument meaning if you did something like:

    Code:
    value = DialogEx.Show("Dialog1");
    Code:
    DialogEx.Close("Hello!");
    value would be set to "Hello!".
  • arb
    Indigo Rose Customer
    • Jul 2007
    • 163

    #2
    Your right it is useful, nice trick; but you mention it late cause i just finished my current project that used lot of dialogs and i used global vriables for those :lol

    Actually you recreate the Dialog.Show function.

    Thank you

    Comment

    • Imagine Programming
      Indigo Rose Customer
      • Apr 2007
      • 4252

      #3
      Nice one Sakuya :yes Thanks.
      Bas Groothedde
      Imagine Programming :: Blog

      AMS8 Plugins
      IMXLH Compiler

      Comment

      • sermak
        Forum Member
        • Feb 2008
        • 162

        #4
        I will ask you, if you can put a example.. because, i think this interesting, but i dont understand very well, what do.. XD

        Comment

        Working...
        X