Author Topic: editing the value of an identifier  (Read 6509 times)

kansas

  • Newbie
  • *
  • Posts: 15
editing the value of an identifier
« on: March 23, 2006, 10:32:23 AM »
i am trying to build a simple calculating script which all is done but one thing

in the calculation formula i need a "constant", the value of this so called constant can change, but does not change often

i have placed it as an identifier and read it into the script which works great but i cant alter the value in the identifier through an alias or script.

i cant use a regular variable since i do not want to update the value of it every time i load icechat (the script will be used by people that have not used irc earlier as well as experienced users)

i was hoping for something like "SetIdentifier" or through alias by some command (ex /update : /set $MyIndentifier = $1)

if there is a way to alter the value of an indetifier without going into ctrl+m then please let me know how

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: editing the value of an identifier
« Reply #1 on: March 23, 2006, 10:46:33 AM »
Well, quite simply put, this can not be done in IceChat 5.

IceChat 7 does have this capability added to it, by using the set command.
The IceChat God

kansas

  • Newbie
  • *
  • Posts: 15
Re: editing the value of an identifier
« Reply #2 on: March 23, 2006, 10:48:31 AM »
ok, then i will download 7 instead and keep working from there

thanks

kansas

  • Newbie
  • *
  • Posts: 15
Re: editing the value of an identifier
« Reply #3 on: March 23, 2006, 11:45:27 AM »
well, the set command works partly only
you can set a variable, but it isnt saved until the next time you open IceChat7

the script that was fully functioning in ver 5.5 doesnt work at all in 7 (its an OUTTEXT script)

i will make my own variable file in 5.5 instead, hopefully i can get that to work instead

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: editing the value of an identifier
« Reply #4 on: March 23, 2006, 12:36:58 PM »
Well, if you are going to using the VBS Style scripting in IceChat7, you have to make sure when you save the file, that you save it as a IceChat 5 Script, because the default script engine in Ver7 is not that same style.

If you want to set a variable, and save it for use on next startup, thats quite different, as the variables are not saved to a file, they are only kept in memory. You will want to save the value to a file, and get the script to read the value from the file, etc etc.
The IceChat God

kansas

  • Newbie
  • *
  • Posts: 15
Re: editing the value of an identifier
« Reply #5 on: March 24, 2006, 12:10:49 PM »
still having some problems and would appriciate some help

i can write to a file (just one line but at the moment that is enough)

reading from the file is the part that wont work
this wont work for some reason
ModVar = Varfile.Read(3)
ModVar = Varfile.Readline(0)
ModVar = Varfile.Readline

the error message i get
060324 20:41:47 -- Script Engine Error:54:Bad file mode: Line #18 --

please help
Code: [Select]

Function OUTTEXT(OutgoingText)   
Dim i, Data, lenght, exp, ModWeap

Data=Split(OutGoingText," ")   
i = ubound(data)   
if i = 0 then   
  length = len(Data(i))   
  if length  < 6 then     
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set VarFile = fs.CreateTextFile("variables.var", True)
      ModVar = Varfile.Read(3)
      VarFile.close
      Data(i) = Data(i)*ModVar
  end if
end if   
'   
OutText = Join(Data, " ")   
End Function   

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: editing the value of an identifier
« Reply #6 on: March 24, 2006, 12:18:59 PM »
You are using CreateTextFile. This creates a file. You can not read anything from a file you just created. You want to use the OpenTextFile method.
The IceChat God

kansas

  • Newbie
  • *
  • Posts: 15
Re: editing the value of an identifier
« Reply #7 on: March 24, 2006, 12:20:42 PM »
oops, my error

Set VarFile = fs.CreateTextFile("variables.var", True)

that recreates the file

works alot better with
Set VarFile = fs.OpenTextFile("variables.var", ForReading)
 :-P

i have another problem though
i cant get an alias to work

/add:/!SetVar $1

Sub SetVar(variable)

can anyone tell me how to create this alias?

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: editing the value of an identifier
« Reply #8 on: March 24, 2006, 12:23:36 PM »
You should not be doing /!Setvar, you need a space, /! Setvar. The /! command tells icechat to use a VBS Command, /!Setvar would be an invalid command.
The IceChat God

kansas

  • Newbie
  • *
  • Posts: 15
Re: editing the value of an identifier
« Reply #9 on: March 24, 2006, 12:27:54 PM »
ahhh, great

thanks alot, everthing works now

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: editing the value of an identifier
« Reply #10 on: March 24, 2006, 12:31:40 PM »
Excellent.

If you want to post the script or email it, I could make sure it works in IceChat 7. There may be some commands that are not working 100% yet in ver7, its still in development.

The IceChat God