mIRC Home    About    Download    Register    News    Help

Print Thread
Question about variables and saving into file #231946 11/05/11 07:11 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
i saw a topic where it says how to save in ini file

this
Code:
//writeini txt.ini $chan

if i want to save a message lets say
Code:
.say Hahahaha

if i want to save the "hahahaha into the ini and specify what channel it from do i need to do a variable that will store the line first before saving it?

Last edited by Kreuz123123; 11/05/11 07:58 AM.
Re: Question about variables and saving into file [Re: Kreuz123123] #231947 11/05/11 08:18 AM
Joined: Mar 2010
Posts: 144
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 144
In the example that you provide you don't need to use variables. It depends on what really want to do and how.
I've written an example for you:
Code:
on *:Text:*:#:{
  ; Here we check if the message is the command that you want
  if ($1 == .say) {

    ; Now we're checking to make sure that the text after the command isn't empty
    if ($2 != $null) {

      ; Now we're saving the text into the INI file, The topic name would be the channel name,
      ; and the item name is the index of the item where it listed in the INI file.
      ; Note: I've used the index as the name of the item, but you might use anything else...

      ; $ini(File,Topic,0) will return to total items in a topic, So we'll use it and calulate it +1 to
      ; determine the item name.
      .writeini myINI.ini $chan $calc($ini(myINI.ini,$chan,0) + 1) $2-
    }
  }
}

Now, to read the data from the INI file, you can use:
Code:
$readini(File,Topic,N)

"File" is your INI file,
"Topic" would be the channel name (I used the channel name, you might use anything),
"N" is the number (Name) of the item. (Which we used a number as the item name.)

Good luck.

EDIT: The code corrected.

Last edited by Masoud; 11/05/11 10:28 AM.

Nothing...
Re: Question about variables and saving into file [Re: Masoud] #231948 11/05/11 08:50 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
Thank you for the example smile i have 2 following questios
1. where the Ini file saves? to what folder?
2. the code
Code:
$readini(File,Topic,N)

if i change "Topic" to "$chan" will it pick the current chan the user in if its in the ini file?

Re: Question about variables and saving into file [Re: Kreuz123123] #231949 11/05/11 09:06 AM
Joined: Feb 2011
Posts: 367
K
KindOne Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 367
I think (not entirely sure) the .ini file will be saved in the $mircdir , since it's the script is not being specific. Or possibly the same folder where the script is.

Just enter this info in a mIRC window, and it will tell you where, if it's saving it in the $mircdir.
Code:
//echo -a $mircdir


irc.swiftirc.net #msl (mIRC Scripting Language)
Re: Question about variables and saving into file [Re: Kreuz123123] #231950 11/05/11 09:10 AM
Joined: Mar 2010
Posts: 144
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 144
Yes, if you use $chan as the topic name, it will pick the channel that the event has triggered.
For the file, you can specify a full path like, D:\MyFolder\my.ini, if you don't specify the path and just write the filename, it will use the root directory of your mIRC.
Pleae note that if the path that you write for the file contains SPACE you have to use quotation (which is $qt) or Short filename (which is $shortfn) otherwise your script will give you error and won't write anything to the file.

Examples:
1)
Code:
$readini($qt(C:\Program Files\mIRC\File.ini),$chan,N)

2)
Code:
$readini($shortfn(C:\Program Files\mIRC\File.ini),$chan,N)


If you have installed the mIRC and it's not portable and you're using Windows Vista/7 it will save the files to "C:\Users\YourUsername\AppData\Roaming\mIRC\". To make sure you can do:
Code:
//run $mircdir


To learn more about it, use the mIRC's help file. and if you couldn't understand anything, ask here and I'll help you smile


Nothing...
Re: Question about variables and saving into file [Re: Masoud] #231953 11/05/11 09:35 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
i tried expanding it but i couldnt get past the second $2 and i cant figure why

Code:
  if ($1 == .orders) { 
    if ($2 == $null) { msg $chan Orders for #channel: }
    elseif ($2 == set) {
      .writeini Orders.ini $calc($ini(Orders.ini,$chan,0) + 1) $3-
      notice $nick The Line was saved into Orders.ini with the channel: $chan and the Orders you specified.
    }
  }


i think i did everything correctly if u put .orders and the second string is empty u put one message but if its set to "set" then do this message and save to file no?

Last edited by Kreuz123123; 11/05/11 09:35 AM.
Re: Question about variables and saving into file [Re: Kreuz123123] #231954 11/05/11 09:54 AM
Joined: Mar 2010
Posts: 144
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 144
Well, this would work when someone writes:
Code:
.orders set message

If the message is empty, then script won't write anything to the file and will break out and throw an error in your active/status window.


Nothing...
Re: Question about variables and saving into file [Re: Masoud] #231955 11/05/11 09:56 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
but i put the "$3-" in there so i tested with .orders set Battle
to try it out and it didnt worked as i planned

ahhh... i forgot " | " between Write ini and notice

but now the problem is the saving it saves like that

Code:
[1]
Battle!=
Test=


i dont think the $chan works

Last edited by Kreuz123123; 11/05/11 10:15 AM.
Re: Question about variables and saving into file [Re: Kreuz123123] #231957 11/05/11 10:26 AM
Joined: Mar 2010
Posts: 144
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 144
My bad, i forgot to write the $chan in the /writeini.
The correction of your code would be like this:
Code:
if ($1 == .orders) { 
  if ($2 == $null) { msg $chan Orders for #channel: }
  elseif ($2 == set) {
    .writeini Orders.ini $chan $calc($ini(Orders.ini,$chan,0) + 1) $3-
    notice $nick The Line was saved into Orders.ini with the channel: $chan and the Orders you specified.
  }
}


Nothing...
Re: Question about variables and saving into file [Re: Masoud] #231958 11/05/11 10:36 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
everything seems to work fine even the Read ini

one this that i cant get read of is the " | " the seperator from Notice and the $3- when i move it near Notice it wont show it but when i move it near $3- it shows the notice but adds " | " to the ini aswell do i need to use $remove for that?

edit: used $remove to delete the " | " it seems to work fine lol now i only need idea on how to improve it maybe instead of Set
ill make Update and it will Rewrite the line but i dunno how xD

Last edited by Kreuz123123; 11/05/11 11:01 AM.
Re: Question about variables and saving into file [Re: Kreuz123123] #231959 11/05/11 11:22 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Nothing would change besides using update instead of set for the command and possibly changing your notice message. And you do not need a | anywhere in that script if you use it the same way it was given to you.


Invision Support
#Invision on irc.irchighway.net
Re: Question about variables and saving into file [Re: Riamus2] #231960 11/05/11 11:55 AM
Joined: May 2011
Posts: 24
K
Kreuz123123 Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: May 2011
Posts: 24
it doesnt work without the | but i already fixed it all

Thanks Masoud for ur help and patience smile thanks alot