Autofill?

Oct 23, 2009 at 1:53pm

Autofill?

Hey all,

Is there a way to create an ‘autofill’ kind of function in Max?

To be specific, I’m looking for a way make some data entry more efficient in a patch, so that while the user is entering some options, Max would assist them by cycling through options.

For example, let’s say there is a umenu with 40 different options, is there a way to set it up so that pressing ‘M’ on the computer keyboard would cycle through all of the options in the umenu that start with ‘M’?

Is this doable?

Cheers,
Joel

#46025
Oct 23, 2009 at 10:53pm

You could work something out using [regexp] certainly, where you put in the key letter you want and Max iterates through the list, grabbing any entry that starts with that letter. Just a couple comparison operators and the [regexp] should be able to do this. getting your brain around regexp in general takes some time but it’s quite powerful, and for simple queries like this it would be straightforward. [sprintf] also comes in handy with stuff like this.

jit.cellblock and [coll] could also be used similarly, if the interface works better for your needs. Sounds like there could be some nice possibilities with such a system, like selecting certain filenames out of a list, or giving various options from a word list.

#165803
Oct 26, 2009 at 6:05pm

Hi there!

Thanks for this. I’ll do some exploration with your suggestions. I’ve finally got my brain around [sprintf] though I don’t really understand how it would apply here. I also haven’t yet figured out why to use that vs. [regexp] vs. [combine], but I’m sure it will be clear.

What do you mean when you say comparison operators? Like a numeric thing or are you think of a ZL function of some kind?

Thanks for pointing me in the right direction…

Cheers,
Joel

#165804
Oct 27, 2009 at 5:13am

sprintf is useful in lots of situations, though maybe not this one. It’s definitely handy with weird text formatting stuff though. For this case, you’ll probably just use regexp.

The “comparison operators” probably was a little unclear… all I meant was using (say) “select m” to find instances of “m” being the first letter of the word, etc. So it’s not like a > or < comparison, it's a select-the-one-you-want. Don't forget the very handy right outlet of select and route, too... sometimes these are more useful than the others, if you want to filter things out.

You can search on here for a regexp tutorial, I know there was one posted awhile back and it was very helpful.

#165805
Oct 27, 2009 at 11:42am

Here’s a javascript which does most of what you want. You need to name your [umenu], then use that name as an argument in the [js] object. Sending a “bang” will re-search the “items” attribute of your [umenu] and sending an integer will look up that ascii value and output the index if it is present in the [umenu], repeated pressing of the same key will cycle through all available indices. Here’s the code and an example patch.

lh

// lh.menunav.js

var mem;
var old_key_code;

function loadbang() {
    bang();
}

function bang() {
    mem = [];
    obj = this.patcher.getnamed(jsarguments[1]);
    memflag = obj.getattr("items");
    for (i=0; i

----------begin_max5_patcher----------
1220.3ocyX01aaaCD9yN+Jt5OaGa4Whc5WFFPKvVQCRQaFv.RCJnjnkXBEoF
IkiSK59suiTVhxIA0xNNFK.Qx2CoIu64diz+3jNcCkqn5tvagqgNc9wIc53f
r.cVK2oaFYUDmncSqqfduL71t8JGxPWYbvFHDBqPEEYLAmZbei.OnrvTgNZM
5BovHHYT2h76JFgWsH4DSTJSj7MEMxTpgiFN7zg8foysOGOw9bDh.2r9qTt9
lGxokyuaHQjzs2520SytmZ12cSJXDtJkvrXmRfVW+QcsP+7jSrO50RlIRlkQ
ElmRMoLMbcANVwM.9wHBmSigu1MDMWwW6tCr1v8g0FO0wZAibzVvYAOg21Ng
LdeHDT2CopW6fhYSJstYtPigaOnfY8Q6dLwY6CEXjIIb5NPAAayPmNsxBaic
VOZCCIX+blOedeBwPgfm0.G8KMv8vGOy4hmzh79cwuFL7+uw1met2k+JFZO4
.FPbG8gmkUF9rrxj8mUFO1wJme5zVxJO80NPQy1GJJrvXjhCS1+5deiOqso+
aFDzvTleHy+k4TQL5tjIvBIO9U+D.Atbg4COcL92jI8fyG0hxA6QNw7CYRQt
hZ4I.eufsZOBH1GRJX3nZVZ9rCaQy4S2G1wcFnJEeIQUaQtSBsCzx3sRKjBi
LWlWvw9SMWGlgls97tcIBCqutHyFdzy9fjmyo5HEK23wLFEIxHUdDbo0jkzZ
fPlnuLxzOktpeLMximC141WQcjYEbTpLG3LMZJ0PbYzcdIIWp.lAXhMvJTfs
caCL2ANAZLqo9EIEBLVfIEM1.YgvP8yIlXHgDsesd+e+oOd4mees7BFmZY1S
uU2.CCgCkIEOBhIxKLfLeyszMjBy57aRRTb8mSIpLHg5sPlPafEJYFTEYTMx
s59ZL6YS4+AJzXXOjQLJ1pHih2X7BVs.Ox6e4LAE0VjHz1jEOLty4Dka8Ro7
75Q7KNDktgojwhYfPZVudKI7MFhSQavinwLeYnWtfaXPHI4QHqKSzvO4v0bF
hAjk94+XWiTgy.uTAWRhqtzia.W4A6taZZw4RMqgjhkQgEtnbcSTgeNJZBcU
dCQElNRaHqwq0zPVZrGLLjD9vapA0QX2BPtv5f0MPURtm8zoRkIpnQxgy7gE
no4UGMlNvZXl5bE4AujQQIYfFcBQodzhrLqG95Ru5+dC1wRg9PAnYIBB2uiW
cI7tKgO9me4pZHy8Rq21OmFgXtxZffrrF4dr7.t3VUfWlJ5GJUhnXVq0M8a0
vemC5hPv1cntL7unzNdaGao8fw02qqUGAx8ue8K6FYqcdAIBmhTmB+w6d6f+
RiYHC3E2QSw6pN3BLSKZvEjUW7kO8AlAC2sBSGbEEya9.YIorjodPceObiWW
jcW5ob1Ari6sZfmdp0wf9EXW6u7Btjhsqq8UvzCbG2flri6K5pm8ne7FmdYw
2jxzXyinpss7W3nG30rXzSxDDWfpeN3V1bRor3Xpn4Y4wJc4XZnQWcDU2gwK
Od97wUeFt4Ycq6hlFrMMcxtoouPUBOA81YuQGWUZZabnmcb0oIsQmldT0oYs
PkNtASAsIXJX3QUmlzVUJ33ELE7JDfWVjJXT4OoD9pR5k5SG9JTd8XPfujBD
nvOO4+TdgaSM
-----------end_max5_patcher-----------

#165806
Oct 27, 2009 at 1:57pm

Wow. Thank you so much, this looks like it may be the answer to my problems!

You sir, are a javascript saint.

Cheers,
Joel

#165807

You must be logged in to reply to this topic.