Wednesday, November 23, 2011

Return if

I'd quite like a return-if construction in lua, or at least I'd like to experiment with one.


It would have the form of something like

<return if>  :=  <opt-whitespace> <if> <opt-whitespace> <function>

Then you could do things like


function someFunction()
    local everyThingHasGoneWrong()
    end

    // code
    return if everythingHasGoneWrong()
    // more code
    return if everyThingHasGoneWrong()
end

The first return arg would be a bool for the if, the second and all those after would be the returns. I'm sure there would be some interesting recursive snippets you could do.

2 comments:

bharathi said...

hi ...
i am running open dialog box in c# i want to one or more files concurrently using loops... then i want to exe.. files .. i opened any files in opendialog the exe will not running..
i press the cancel button of open dialog box the exe will running may i know the reason ..
any help will be greatly appreciated..
thanks in advance here
my coding

TextBox txtfilelocation = new TextBox();
int cancelcount = 0;
OpenFileDialog ofdnew = new OpenFileDialog();
ofdnew.Filter = "xls Files|*.xls|xlsx Files|*.xlsx|Text Files|*.txt";
ofdnew.Title = "Select File";
DialogResult resultnew = new DialogResult();
//runexeDownload();
for(int i=0;i<3;i++)
{
resultnew = ofdnew.ShowDialog();
ofdnew.Filter = "All Files|*.*";
ofdnew.FilterIndex = 2;
ofdnew.RestoreDirectory = true;
ofdnew.Reset();
ofdnew.Dispose();
ofdnew.FileName = "F:\\Documents and Settings\\Origin\\My Documents\\Visual Studio 2008\\Projects\\Test1\\Test1\\bin\\Debug\\Download.txt";
runexeDownload();
////int dialog = 0;
if (resultnew == DialogResult.OK)
{
txtfilelocation.Text = ofdnew.FileName;
}
cancelcount = 0;
while (resultnew == DialogResult.Cancel && cancelcount != 2)
{
cancelcount++;
resultnew = ofdnew.ShowDialog();
if (resultnew == DialogResult.OK)
{
txtfilelocation.Text = ofdnew.FileName;
}
}
if (cancelcount == 2 && resultnew == DialogResult.Cancel)
{
ofdnew.Dispose();
// int filecount = 0;
}


}
//runexeDownload();
}

// reply to my mail id bharathiit09@gmail.com thanks in advance..


**** i think little bit diff to understand the problem doubts on my questions free to mail @ bharathiit09@gmail.com //

balaam said...

It's quite hard to follow what you mean in the first paragraph. Maybe a friend could help you rephrase it?

It sounds like you might want to open multiple files at once from a dialog box. Which should just be a flag I think, it's probably easiest to just browse the visual editor and see if you can find it.