|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
How do you get a name of a window with hash table data with multiple names....
like hash table -- GUI
data -@blah -@boom ...etc...
just ask if you dont understand(I'm making a GUI)
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
the name of any window? or a specific one? If you know the name of it, then.. well, you already have it. If you want the "first" window in your hash table, though-- you can't do that.
Your question is quite vague so I'll go over all the ways to get values from hash tables.
Hash tables don't maintain order, they're a data structure similar to your english dictionary. You have a "key" (the english word) and the corresponding "value" (the definition of the word).. you do lookups by the key name, not by the index number. For instance, because you don't (easily) know how many words are between "aardvark" and "arrow", you can't just say "give me the next word", because there is no simple correlation between one key and the next. They're not maintained that way in memory, so its your job to figure out the next key.
If you want to maintain order in a hash table, make the key a number value ranging from 1-n and then have the value contain the rest of the data.
You can also use $hget(htable,N) where N is a value from 1-size. In this case, mIRC will grab the "Nth" key-- but before you go AHA!, know that the order is not guaranteed. It might pull "arrow" at index 1 and "aardvark" at index 2, for instance. Even though you may have entered them in the other way around.
Finally, you can use $hfind to search for a key name if you know part of the name, like "@b*".. again these results are not ordered, but this might be what you're looking for.
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
if you have ever used the Blizzard GUI from picwin.tk, thats what im talking about, I want it because for mouse events you need a specified window... altough there might be a way... thx for that anyway
what i will try, and i hope it works, is i will create an if statement inside my general code for a highlight and i will create mouse events for a check on the active window(if the hash table name matches the window name)
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
Does this work? menu $active {
sclick:if ($active == $hfind(GUI,$active) { window -c $active }
} and if not, how do i get it to
|
|
|
|
Joined: Sep 2005
Posts: 2,630
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,630 |
Try it yourself you lazy git, then come back and ask for help if it doesn't work.
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
As mentioned, try things first... then ask if it doesn't work. It saves everyone some time.  That said, you're missing a ), so it will not work. And I'm not entirely sure that you're going to get a good comparison in that IF... it will depend on how your hash table is configured. Just try it and see if it works (after adding your missing ) ).
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
alias GUI {
window -pkodCfB +b @GUI -1 -1 400 400
hmake @GUI
hadd @GUI name @GUI
}
menu $active {
sclick: { if ($active == $hfind(GUI,$active) == name) { window -c $active } }
}
heres what i have, i think the hash tables are wrong, can someone fix it please? i just learned them lol
Last edited by foshizzle; 16/01/08 03:05 AM.
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
alias GUI {
window -pkodCfB +b @GUI -1 -1 400 400
$iif($hget(@GUI), hfree @GUI, )
hmake @GUI
}
menu $active {
sclick: { if ($hget($active) == $active) { window -c $active } }
}
still doesnt work...
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
you can't do "menu $active"
$active is meaningless at that level of code
Why would you have the $iif over a regular if statement by the way?
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
idk do u know how i would get this to work though?
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
As I said, menu $active is meaningless.. Follow the proper syntax, type /help menu prefix
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
Use the /window command's ability to use a defined Popup menu: alias GUI {
window -pkodCfB +b @GUI -1 -1 400 400 @MyPopup
if ($hget(@GUI)) { hfree @GUI }
hmake @GUI
hadd @GUI name @GUI
}
menu @MyPopup {
sclick: {
if ($active == $hget(@GUI,name)) {
window -c $active
}
}
} Something like that perhaps.. although the point of the hash table at this point is.. well, there isn't a point.
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
i know, with that, but i want this to be a GUI, so i need multiple windows.. thus requiring some way to tell if a window is a GUI window....
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
but you see, you know its a GUI window because you made the menu specifically for that window name
"menu @MyPopup {"
AFAIK, you cannot make a menu for an arbitrary custom window, so you will always know the menu you made is for a specific window. This goes back to how i said "menu $active" is meaningless, and that you should consult /help menu prefix
|
|
|
|
Joined: Aug 2007
Posts: 331
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Aug 2007
Posts: 331 |
I know that, but do u know any way around it?
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Try something like this...
menu * {
$iif(@* iswm $window($active),GUI):Do something here
}
If you need the menu to only work for custom windows starting with "@GUI", then put "@GUI*" instead of "@*". Granted, that doesn't give sclick ability, but you may be able to work around needing that depending what you're doing.
|
|
|
|
Joined: Jan 2003
Posts: 2,125
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,125 |
Small sidenote, $window($active) is the same as $active (as the latter always returns the name of an existing window (or $null, although that wouldn't happen in popups)).
|
|
|
|
|