mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Hello im looking to store info into a hash file and getting it how is it done?

for example

if i wanted my script to be something like

Code:
on *:TEXT:*:#: {
if ($1 == !News) && ($2 == Recent) {
msg $chan read hash table right here if multiple lines in hash file is also  i want to know to get them
}
}


thank you in advance


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Very simple example:

; Make a table ("5" is 10% of what you expect the total number of items to be)
/hmake MyTable 5

; Format for adding items:
; /hadd TABLENAME ITEMNAME DATA
/hadd MyTable Name Riamus
/hadd MyTable Address 123 Main Street, Anytown, USA
/hadd MyTable PhoneNumber 123-555-1234

; Get the number of items in the table
//echo -a $hget(MyTable,0).item

; Get an item by name
//echo -a $hget(MyTable,Name)

; Get the item name of item #__ in the table (assuming none of your item names are numbers)
//echo -a $hget(MyTable,1).item

; Get the data of item #__ in the table (assuming none of your item names are numbers)
//echo -a $hget(MyTable,1).data

; Remove a hash table from memory
/hfree MyTable

; Load / Save a hash table to a file
/hload MyTable filename.ext
/hsave MyTable filename.ext

As I said, that's a basic example of how to do some of the things with hash tables. For more specifics, ask a specific question. laugh


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Alias>:
Code:
alias news.upd {
writeini news.ini $adate Hot_Topic $1
;basic writeini file Hot Topic like Stocks
writeini news.ini $adate News $2-
}


usage i normal have for this is similar to so that if i type !addnews stocks WED is up by .02 cents while S is down $2.31

updates Newsini with current date and adds hot_topic and news..

now the problem is I have a HUGE ini file which takes a long time if accessed by archives none the less system ressources are used I heard that Hash Tables make this a smooth transaction

Code:
on @10:TEXT:*:#: {
if ($1 == !AddNews) { 
writeini archivenews.ini (Here i have a script but basically to tell ya im simply writting whats on the current news to the archive ini)
$news.upd($2,$3-) 
}
msg $chan echo -a News has been updated on $adate at $time(hh:mm:nn) $+ .
} 



Code:
on *:TEXT:*:#: {
if ($1 == !News) && ($2 == Recent) {
msg $chan read hash table right here if multiple lines in hash file is also  i want to know to get them
}
elseif ($1 == !News) && ($2 == Archive) {
play ( get hash table right here archives)
}
}


so basically what i need is the Hash table to read the current recent News when

!news Recent

and if !news Archive to play the hash table.

so by what your telling me

/hmake News 5
/Hadd News Hot_Topic Stocks
/Hadd News News Wed is up by .02 cents

on *:TEXT:*:#: {
if ($1 == !News) && ($2 == Recent) {
msg $chan $hget(news,1).item $+ : $hget(news,1).data
msg $chan $hget(news,2).item $+ : $hget(news,2).data
}
hfree News
}

right?

Last edited by Lpfix5; 07/10/05 08:46 PM.

Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Um i just notice also I can use /hsave News whatever.hsh

and i can read it with notepad or whatever but if i /hfree news then try to /hload News whatever.hsh it wont work says no such table.. even though whatever.hsh is present


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2005
Posts: 6
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: Aug 2005
Posts: 6
You have to create a table to load whatever.hsh into.


Hope is an illusion. Fate is a lie.
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
OH yeah i see


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard