|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
How much can a variable hold? And is there a way to increase it?
Thanks
Ninko
|
|
|
|
Joined: Feb 2008
Posts: 4
Self-satisified door
|
Self-satisified door
Joined: Feb 2008
Posts: 4 |
variables can go as high or as low as you like, to increase just use /inc %variable (number to increase by) it will show in status, if you dont want it shown use .inc instead :-)
|
|
|
|
Joined: Dec 2002
Posts: 2,033
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,033 |
I believe the variable length limit is around 940 characters. You would have to make a request to get the limit raised or removed if possible, as several others have in the past. ~ Edit ~ The limit also includes the variable name itself.
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
A way to increase it? No. You can use Binary Variables which are only limited by the capacity of your RAM.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Besides the ~940 limit on normal variables that can be avoided by using binary variables, actual numbers can only be so large if you're going to manipulate them (such as with $calc). I believe I figured it out in the past to be a either 20bit or 24bit limit on number size before it "loops" into the negatives. I don't feel like figuring it out again, so if that's not the correct size, someone can correct it.
EDIT: Hm, I don't know that "bit" was right for that. I'll look into it and figure it out again.
Last edited by Riamus2; 26/02/08 11:42 PM.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
$calc() is fine for up to 52bit numbers (4503599627370496+) or so.
hinc and hdec had some issues with 32bit numbers however. I think they've been resolved though.
Last edited by Bekar; 27/02/08 01:33 AM.
|
|
|
|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
The problem I'm having is I'd like to get info from a website which has all its code on ONE line, but everything I've tryed so far just says the line is too long.
Any ideas?
Thanks
Ninko
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
Joined: Jan 2004
Posts: 509 |
Sounds like sockets. $1- is too long? Or even setting a variable to $1-?
How about $1-20
Or $gettok().
|
|
|
|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
When reading the one line it says its too big for the variable. I just want to be able to get the one line, echo it so I can check its all ok and then process it from there.
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
Joined: Jan 2004
Posts: 509 |
If the line is too big for the variable, so that the variable is never set, then try not setting the entire line for the variable?
Anyways, the maximum length that a variable can store also has to do with how many letters the variable's name is. But that probably won't help much..
|
|
|
|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
How do I set it to more then one variable when its all written on one line, doesn't sockets read a line at a time?
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
Joined: Jan 2004
Posts: 509 |
Is the entire line $1-?
If the line is $1-...
Then try.
/set %variable1 $1-20 /set %variable2 $21-40 /set %variable3 $41-60
Or something more complicated.
|
|
|
|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
I don't really understand (I'm new at some of this), how would that work when reading from a socket? on *:sockread:test:{
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
echo -a %temptext
}
}
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
In order to read in the whole line the easiest way would be to use a binary variable since they have no line length limit. Unfortunately you can't use standard identifiers/commands with binary variables, they can only be accessed and manipulated through specific commands and identifiers, making them a bit harder to work with. To read the socket data into a binary variable you would use the following (from within the "on SOCKREAD" event): sockread -fn &data
; The binary variable "&data" contains the contents of the webpage See the "Binary Variables" section of the help file for details of the commands to access binary variables. Exactly how you'll use them depends on precisely what you want to do. It may be a case of breaking the contents up into multiple lines so that they can be assigned to regular variables, or it could be as simple as saving the binary variable into a file and reading the relevant data from there.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
Joined: Jan 2004
Posts: 509 |
I don't really understand (I'm new at some of this), how would that work when reading from a socket? on *:sockread:test:{
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
echo -a %temptext
}
}
I had to download mIRC to read the mIRC help file on the school's computer in order to read up on sockread. Since it stores the entire text into the variable (and variables have limits), well, binvars don't have limits, so try that. But I don't know a way of getting around it. I'd debug and echo -a $1- just to see what it returns. : /
|
|
|
|
Joined: Jun 2004
Posts: 139
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 139 |
It says only /bread and /bwrite can be used with binary variables, but I'm not quite sure how they can be used, eg on *:sockread:test:{
if ($sockerr) {
echo -a Error.
halt
}
else {
sockread &temptext
echo -a /bread &temptext
}
}
doesn't work.
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
/bread is for reading the contents of a file into a binary variable. To access the contents of the binary variable from a script, use the $bvar() identifier (eg. $bvar(&data, 1, 900).text would return everything between the 1st and 901st bytes of data).
Note that you can't echo more than the line-length limit at once since it's actually a limitation of the script parser, not something specific to text variables. So if you want to echo the whole contents of the file you'll have to loop through peice by peice - ideally using $bfind() split the data at appropriate places (ie. not in the middle of an attribute or a word).
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Once you have the data in a binary variable, you use $bvar to read a "piece" of it that is small enough to work with. /bread and /bwrite let you write the variable to a file or read a file into a variable.
You have the option of either going through using $bvar and getting what you need or else /bwrite'ing it to a text file and manipulating the text file so it's not all on one line and then $read'ing the text in like normal.
If you have any other locations to get the data other than a site that puts everything on one line, you'd save yourself a lot of trouble using a different site. Besides, sites that stick everything on one line are badly written, imo.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
You cannot use $1- because there isn't a $1- to begin with. You could tokenize something from a socket and then use $1-, but that won't be possible if the line is too long. The only method is to use binary variables.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
Joined: Jan 2004
Posts: 509 |
|
|
|
|
|