|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
i trying to list $chr() in to a dialog, that working ok, how ever i cant get $gettok to work as it should. $gettok($did(3).sel,1,48) echo the right number untill it's 10 - 20 - 30 and so on, it skip the numbers with 0 in them, how can i solve this? by the way, i will load the value's i get to 6 and 8.
alias chr { if (!$dialog(chr)) { dialog -m chr chr } }
dialog chr {
title " Characters [ /char ]"
size -1 -1 140 180
option dbu
button "&Close",1, 40 160 60 15, ok
box "",2, 1 0 138 179
list 3, 5 8 130 130, size
text "Find:",4, 15 145 15 7
text "Char:",5, 38 145 15 7
edit "",6, 53 143 20 11, limit 1
text "Num:",7, 85 145 15 7, read
edit "",8, 100 143 20 11, limit 3
}
on *:dialog:chr:*:*:{
if ($devent == init) {
var %x = 0
while (%x < 255) {
inc %x
did -a $dname 3 $chr(35) $+ %x $chr(9) $chr(%x)
}
}
if ($devent == sclick) {
if ($did == 3) {
echo -a -> $gettok($did(3).sel,1,48)
}
}
}
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
This is the most ridiculous question I've seen you ask out of the many you've posted over the years on this message board, and is the last time I'm going to help you because you clearly don't even bother trying to figure out the problem before running to us.
$chr(48) = 0, so when you do $gettok($did(3).sel,1,48), you get the first token separated by 0. This means that in 30, $gettok(30,1,48) will be 3. Remove the $gettok and just use $did(3).sel instead.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I'm new to $gettok, not everyone can the scripting language at once. and you say it was "the most ridiculous question I've seen", how ever Since i learning and it's no good tutorials. atlest i don't understand them, then i need to ask. And since i want to learn i ask on the forum, but you pointed me in the right direction. 48 replaced with 47 did the trick.
$gettok($did(3).sel,1,47)
And i want to use $gettok since in need to grab the other info in the dialog for later use, and i think it's good to learn new things.
By the way, i havent been trying to write any scripts for a cupple of years now, i just started again, and people can forget things.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Oct 2006
Posts: 166
Vogon poet
|
Vogon poet
Joined: Oct 2006
Posts: 166 |
dude, spend some time reading the helpfile as we all did instead of posting "I won't say silly, I would say easy (because everyone needs to learn somehow and we I don't blame you" questions. please take your time reading the WHOLE helpfile because I'm sure you'll gonna benefit from it way too long.
Kind Regards, blink
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
from the help file: ;------------------------------------------- $gettok(text,N,C) Returns the Nth token in text. $gettok(a.b.c.d.e,3,46) returns c $gettok(a.b.c.d.e,9,46) returns $null You can also specify a range of tokens: $gettok(a.b.c.d.e,2-,46) returns 2nd token onwards b.c.d.e $gettok(a.b.c.d.e,2-4,46) returns tokens 2 through 4 b.c.d You can specify a negative value for N. ;------------------------------------------ I dont understand how it working from that, then i have been reading from: http://www.mircscripts.org/archive.php?s...&perpage=50 And i still dont understand exactly what it does, and after been reading there i asked on #help.script @ quakenet, and they said "read tutorials", and i can't say i found any tutorials out there that explains it so i understand. The one that explained it best was Teazle with the snippets $gettok2. Instead of flame me, why not point out a good tutorial/snippets if you know about any.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
For one thing, you seem to be asking the wrong questions, not just to us but, I suspect, to yourself. In your first post for example you said i trying to list $chr() in to a dialog, that working ok, how ever i cant get $gettok to work as it should. $gettok($did(3).sel,1,48) echo the right number untill it's 10 - 20 - 30 and so on, it skip the numbers with 0 in them, how can i solve this? That's very different from "I don't know what $gettok does" or "can somebody explain this and that about $gettok" or "what does $gettok's third parameter mean?". You don't just go write entire scripts that make no sense and then ask why they "don't work as they should". You first try to fully understand the components you (think you) need. However the only questions I remember from you are of the sort "how can I make that work". These imply that you just want to get something to work, without knowing why/how it works. This way, you have managed to ask thousands of questions without actually gaining any signifant knowledge. This does annoy the forum readers/helpers as it shows a lack of respect towards them: wasting their time by posting again and again, without taking the time to really learn and understand the stuff. I don't know if that's what you really do, but it certainly appears this way to the readers. So, about $gettok. What is it in particular that you don't understand? Is it a specific parameter that confuses you? Have you tried experimenting with //echo -a and various instances of $gettok, each with different parameters? In the vast majority of cases, executing a few //echo -a <thing you don't understand> from within a mirc editbox shows you a pattern that helps you deduce the function of the thing you're testing.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
You asked if i tryed with echo, yes. Look at the question i had.
echo -a -> $gettok($did(3).sel,1,48)
so i did. And i also trying to understand what the codes i get does, and if i dont understand i ask here. And i often get help, then i try figure out why my code didnt work, but it working if i change that to that. And i lernt allot here, and whats the point in have this forum if u cant ask questions in it?
And i don't understand this: $gettok($did(3).sel,1,47) <- return exactly the same as did(3).sel , and when i using that i get called "lame" cos i don't use $gettok, so i try to learn, and yes, i made a error, i used 48 instead of 47, a misstake from my side, and as im new to it i do errors, same goes for all the code i writing, i could just rip from other scripts, but i want to learn, so then i turn to you guys, but i stop if i just waste your time.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
You seem to have missed the points in my previous post. About /echo, you didn't exactly experiment with //echo and $gettok, using different parameters each time, to see how it works in general, you just stuck an /echo in front of a specific $gettok, assuming that it was what you needed. When you want to figure out how an identifier works, you should: - start with the simplest form possible. That means, you don't use other identifiers as parameters of the one you're testing. For example, //echo -a $gettok(1/2,3,48) is a suitable way of testing it; //echo -a $gettok($did(3),3,48) is not. Don't use irrelevant identifiers, like $did(3) or anything else whose value you don't directly know. Focus only on the identifier you want to test, using plain text as much as possible for its parameters.
- try as many combinations of parameters as necessary, that is until you start to see a pattern. You don't get what 48 does? Try another number in its place and see what the difference is. Do that A LOT of times until you get it.
[...] i could just rip from other scripts, but i want to learn, so then i turn to you guys, but i stop if i just waste your time. If what you understood from my previous post is "asking questions to learn is wasting our times", please read it again more carefully. My point was exactly that you give the impression that you don't want to actually learn, you just want to get things done.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I'm new to $gettok, not everyone can the scripting language at once. You've been here since 2003, and I've lost count of how many times people have told you about the mIRC help file. I understand that you might've forgotten how to script, but you can learn in the same way you could 3/4 years ago: by reading the help file. Perhaps if you don't understand something, you should post the script and ask how to find the answers for yourself? That way you'll learn as well as be pointed in the right direction. In this case, to figure out what was wrong, all you had to do was check what character has the ascii number of 48 by typing //echo -a $chr(48). How did you come up with the number 48 in the first place? I'm guessing you typed //echo -a $asc(/), and then memorised the wrong number in your head. $gettok() is incredibly simple. It simply splits a string into pieces at each point where the character specified is found, and then returns the Nth piece. $gettok(a.b.c.d,1,46) mIRC will split the string into four tokens: a b c d This is because you've specified 46 as the final parameter, which is the asc number for a dot: . Now, mIRC will return the 1st token in that list, because you specified 1 in the second parameter. The first token is 'a' Similar examples: $gettok(a!b c!d e f!g,3,33) Tokens: a b c d e f g This is because 33 is the ascii number for an exclamation point: ! mIRC returns 'd e f' because that is the third token. However, if you were to supply 32 as the ascii number instead (a space), the tokens would be: a!b c!d e f!g It's not really mindblowing stuff, and the help file explains it in-depth. I'm not sure what you couldn't work out from the help file, are you sure you read it thoroughly, more than once? 48 replaced with 47 did the trick.
$gettok($did(3).sel,1,47)
Do you not think this is something you could've worked out yourself from the start? If something isn't working properly, echo each of the parameters you're passing to the identifier just to make sure you're passing what you're supposed to. If you're passing things like ascii numbers as parameters, then try finding out what their character is by typing //echo -a $chr(<ascii number>) - that will at the very least let you know whether you're using the right number or not. What you need to do is learn how to debug your own scripts.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I'm new to $gettok, not everyone can the scripting language at once. You've been here since 2003, and I've lost count of how many times people have told you about the mIRC help file. I understand that you might've forgotten how to script, but you can learn in the same way you could 3/4 years ago: by reading the help file. Yes, on and off i have been here, but i have been doing other things from time to time, so even due i have been a "member" here since 2003 dosent meen i have been coding all the time since that year. Perhaps if you don't understand something, you should post the script and ask how to find the answers for yourself? That way you'll learn as well as be pointed in the right direction.
I dont know if i have asked someone to "write" me a script, i have been asking "how do i solve this", and i have been reading the code people helped me with, also been trying to understand them, last time i did that was today, the person that helped me broke down the code, then explained what every line does, how ever i dont use the same code all the time, so need to ask again if i dont understand something that is new to me. In this case, to figure out what was wrong, all you had to do was check what character has the ascii number of 48 by typing //echo -a $chr(48). How did you come up with the number 48 in the first place? I'm guessing you typed //echo -a $asc(/), and then memorised the wrong number in your head.
I asked in a channel, and they told me that i had to figure out it by my self, i tryed to echo the output to me many times, and i couldent get that part to work, and the number 48 was given to me as "the right number to use in this event". $gettok() is incredibly simple. It simply splits a string into pieces at each point where the character specified is found, and then returns the Nth piece. $gettok(a.b.c.d,1,46) mIRC will split the string into four tokens: a b c d This is because you've specified 46 as the final parameter, which is the asc number for a dot: . Now, mIRC will return the 1st token in that list, because you specified 1 in the second parameter. The first token is 'a' Similar examples: $gettok(a!b c!d e f!g,3,33) Tokens: a b c d e f g This is because 33 is the ascii number for an exclamation point: ! mIRC returns 'd e f' because that is the third token. However, if you were to supply 32 as the ascii number instead (a space), the tokens would be: a!b c!d e f!g It's not really mindblowing stuff, and the help file explains it in-depth. I'm not sure what you couldn't work out from the help file, are you sure you read it thoroughly, more than once? 48 replaced with 47 did the trick.
$gettok($did(3).sel,1,47)
Do you not think this is something you could've worked out yourself from the start? If something isn't working properly, echo each of the parameters you're passing to the identifier just to make sure you're passing what you're supposed to. If you're passing things like ascii numbers as parameters, then try finding out what their character is by typing //echo -a $chr(<ascii number>) - that will at the very least let you know whether you're using the right number or not. What you need to do is learn how to debug your own scripts. I trying to understand the code, but i didnt, so i scripted around it instead, but the result would be slower then what you would get. And i trying to debug my script, i even asked here what the best way way, i got a code as answer, but nothing explained what it did. so i still know as mutch now as i did befor about it. But im done flame about it here. I solved my problem, and i now know a litle bit more about it then i did when i woke up this morning.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Mar 2007
Posts: 218
Fjord artisan
|
Fjord artisan
Joined: Mar 2007
Posts: 218 |
Looking forward to the next thread!
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
I think the point people are trying to make is to start smaller. Don't try to write a huge script if you don't know some basic things first. Start out with smaller scripts that are easier to handle until you learn enough to handle larger scripts. Based on your number of questions, it does appear that you are trying to write large scripts that you simply aren't ready for.
If you don't understand a specific command/identifier, read the help file, or ask about it with specific questions. Don't try to work around something you don't understand as that will just cause you more trouble.
As mentioned, $gettok is really easy. Think of it like separating words. You know how to count the words in a sentence, right? You also know how to count the sentences in a paragraph, right? It's the same idea.
$gettok(text,word number,separator)
Sample text located in the %text variable: "This is a test sentence. This is another sentence."
You know by looking at it, that the 3rd word is "a". You are figuring out the word number by separating the text by spaces. If you were counting sentences, you would separate the text by periods (assuming all sentences ended in periods rather than other punctuation marks). Well, the ASCII character for a space is 32. For a period, it's 46. So, let's look at the text using $gettok (remember that the text is located in the %text variable in this example).
$gettok(%text,3,32)
That will tell you the 3rd word (3 = 3rd item, 32 = space as mentioned previously).
$gettok(%text,2,46)
That will tell you the second sentence (2 = 2nd item, 46 = period as mentioned previously).
You can also count the total items using $gettok by using 0 as the item number...
$gettok(%text,0,32)
That will tell you the number of words (separated by spaces). Of course, $numtok does this in less text because you don't need the item number.
Now, keeping that in mind, you can separate the items (aka words) using other characters rather than spaces or periods. Maybe you want to find the Xth item in a list of items separated by commas. If so, you'd use the item number you want to find for the second parameter and 44 as the separator number. 44 = comma.
If you need to find out what number to use, type:
//echo -a $asc(character)
Replace "character" with the character you want to look up. For example, a period...
//echo -a $asc(.)
Note that some characters cannot be displayed with $asc due to how mIRC parses information. Two examples are spaces (32) and commas (44).
Note that all token identifiers work the same basic way. Just read the help file to find out the syntax.
As far as asking for help in channels, I'd suggest finding a channel that is more helpful. There are good scripting help channels and bad ones. If they aren't being much help, then try a different one. Ones that I used in the past were on DALnet, but I don't think they are still around.
Anyhow, like I said, you really should just start smaller and then work your way up. Don't mess with dialogs until you understand how to use basic scripting. Don't mess with sockets until you understand how to use basic scripting. Don't try to write a "full" script until you understand how to use basic scripting. Etc. This is why programming books start you out with how to display "Hello world!" to your screen before they teach you how to write a game or some other more complex thing.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|