reading from MQ2HUD.ini in a macro...

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

reading from MQ2HUD.ini in a macro...

Post by Rusty~ » Mon Aug 23, 2004 1:47 pm

i'm trying to write a macro that reads from the MQ2HUD.ini file so i can make quick easy changes to whole parts of it at once. for example, moving the group window part of it all at once... without having to manually change every x,y loc.

i ran into a problem though when i read from the ini file, it will parse all of the MQData variables in the ini when i read it. i tried using /noparse, but it doesn't do what im looking for. here's a little bit of the code i have:

Code: Select all

Sub Main
   /declare iniName string outer mqpath\MQ2HUD.ini
   /declare key string outer HUDName
   /declare valueList string outer ${Ini[${iniName},${key}]}
   /declare value string local
   /declare line string local
   /declare x int local
   /declare y int local
   /declare i int local
   /declare j int local
   /declare n int local 

   /varcalc n ${valueList.Count[|]}-1

   /for i 1 to ${n}
      /varset value ${valueList.Arg[${i},|]}
      
   
      /varset line ${Ini[${iniName},${key},${value}]}
      /echo ${line}
|      /ini "${iniName}" ${key} ${value} "${line}"
   /next i

if the line in the ini file is:

Code: Select all

TargetHpPct=   3,702,668,255,255,255,${If[${Target.PctHPs}<=100,${Target.PctHPs},]}
and i have a target at say 100% hp, it will echo

Code: Select all

3,702,668,255,255,255,100
i guess i could read the key one character at a time, and work with it from there, but wondering if there's some other way i'm missing

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Aug 23, 2004 3:46 pm

I ran into the same problem, trying to do something along the same lines. The problem doesn't lie in parsing the data from the file.

Code: Select all

/varset line ${Ini[${iniName},${key},${value}]} 
Does what you want, the values are in there. The problem comes when you try to get ${line} to do anything. You can use ${string.Arg[X,","]} to get at the values for x,y, etc. Clever use of ${string.Right[X]} will even get you the "meat" of the line (I couldn't find a way to do it with Arg or Token, due to most lines containing nested commas). Even then, you'll have problems trying to do any output with the string, writing it to screen or file. I had SOME luck (I think..memory's hazy) with

Code: Select all

/docommand /echo ${line}
or maybe

Code: Select all

/vardata somenewstring line.Whatever[]
but it was at right about that point that I gave up, and decided that just putting some custom hacks in my MQ2HUD.cpp would do what I wanted without beating my head against the wall of embedded mq2data in text strings.

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Mon Aug 23, 2004 4:39 pm

well i got this to work but it's really slow...

Code: Select all

   /for i 1 to ${n}
      /varset value ${valueList.Arg[${i},|]}
      /varset line 
      /for j 1 to ${Ini[${iniName},${key},${value}].Length}
         /varset tempChar ${Ini[${iniName},${key},${value}].Mid[${j},1]}
         /if ( ${tempChar.Equal[$]} ) /varset tempChar @
         /varset line ${line}${tempChar}
      /next j
      /echo ${line}
   /next i
it just reads each char, and changes the $ to @... then i could change the x,y, whatever, and rewrite it, changing the @'s back to $'s... but as i said, it's really slow.