Menus

Sora574
16 May 2013, 20:55
Okay, first, to clear it up:
Is 'ShowMenu()' the menu we use now? Or should we be using 'show menu'?

The reason I ask is that if it's 'ShowMenu()', that creates a slight problem.
The ShowMenu() function apparently can't have an outside variable; for example:
blah = "blah"
ShowMenu ("Blah?", Split ("blah; blah blah", "; ") , false) {
if (result = blah) {
msg ("BLAH!")
}
else if (result = blah + " " + blah) {
msg ("Blah.")
}
}

This spits out an error in Quest when you choose from the menu:
Error running script: Error compiling expression 'blah': Unknown object or variable 'blah'

However, 'show menu' doesn't seem to have this problem at all.

HegemonKhan
16 May 2013, 23:43
I think that "showmenu ()" was for a prior (pre-5.3) version, the current one is now "show menu ("blah", split ("blah;blah",";"), false~true)"

(I thought "show menu" got its syntax~structure altered a bit in v5.4, but it doesn't seem to be any different in v5.4 from v5.3)

Sora574
16 May 2013, 23:56
Are you sure?
That's what I thought, but I've found several things saying that's wrong...

viewtopic.php?f=10&t=3521 (the very beginning - stating that they're in text now)
viewtopic.php?f=10&t=3669#p24475
Pertex wrote:The wiki isn't up to date. There is a new ShowMenu command now which creates a text menu, not a popup menu


Those 2 along with several other things... (I don't feel like searching for the others :roll: )

EDIT: Changed the quote to an actual quote.

HegemonKhan
17 May 2013, 00:01
nvm then, I'm not up to date on the new changes, my bad.

jaynabonne
17 May 2013, 00:14
ShowMenu is implemented as a function in Core.aslx, and so it doesn't capture the current variables the way the more built-in (non-ASLX) functions do, like "ask" and "show menu". For your own functions, you can use the "closure" library I wrote as a way to capture both a script and its variables. But for core ones that only take a script, you just have to store the variables you want to preserve in an object somewhere.

Sora574
19 May 2013, 01:14
That seems... lazy.
I see it as a bug that regular functions can't use external variables. JavaScript can do it, so why can't Quest? :|