getting decimal numbers

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

caj
a hill giant
a hill giant
Posts: 244
Joined: Tue Sep 12, 2006 9:35 am

getting decimal numbers

Post by caj » Tue Mar 22, 2011 7:45 pm

I have search and got plenty of info but no examples in how to go about showing a decimal. Ive tried the ${Float.Centi} line w/o any luck. Any hint/advice/link to what im doing wrong.

heres what i have so far.

Code: Select all

#event tmr "#*#This zone has been running for #1#:#2#:#3#:#4#"

Sub Main
/uptime
/delay 2s
/doevents
/end


sub event_tmr(int,Dys,Hrs,Mns)
  /declare tday int outer
  /echo ${Dys} : ${Hrs} : ${Mns}
  /varcalc tday ${Float[${Math.Calc[${Dys}/24]}+${Hrs}*.05].Centi}
  /echo ${tday}
/end
if i take the ${Float.Centi} away i get a number w/o the .00 with the float.centi I just get a 0(zero) return. Im starting to believe its not possible to return a number in decimals or at least wont /echo it back. I dunno. im quite baffled atm.

(hell i will even read through a flame as long as it gives me an idea what im trying to accomplish)

User avatar
htw
a grimling bloodguard
a grimling bloodguard
Posts: 512
Joined: Wed Feb 18, 2004 8:30 pm
Location: Albuquerque, NM USA
Contact:

Re: getting decimal numbers

Post by htw » Tue Mar 22, 2011 8:22 pm

caj wrote:I have search and got plenty of info but no examples in how to go about showing a decimal. Ive tried the ${Float.Centi} line w/o any luck. Any hint/advice/link to what im doing wrong.

heres what i have so far.

Code: Select all

#event tmr "#*#This zone has been running for #1#:#2#:#3#:#4#"

Sub Main
/uptime
/delay 2s
/doevents
/end


sub event_tmr(int,Dys,Hrs,Mns)
  /declare tday int outer
  /echo ${Dys} : ${Hrs} : ${Mns}
  /varcalc tday ${Float[${Math.Calc[${Dys}/24]}+${Hrs}*.05].Centi}
  /echo ${tday}
/end
if i take the ${Float.Centi} away i get a number w/o the .00 with the float.centi I just get a 0(zero) return. Im starting to believe its not possible to return a number in decimals or at least wont /echo it back. I dunno. im quite baffled atm.

(hell i will even read through a flame as long as it gives me an idea what im trying to accomplish)

If you want float output, don't you want to declare it as a float, and not an int?

-> /declare tday int outer
-> /declare tday float outer

caj
a hill giant
a hill giant
Posts: 244
Joined: Tue Sep 12, 2006 9:35 am

Re: getting decimal numbers

Post by caj » Tue Mar 22, 2011 8:25 pm

had an "aha" moment after looking at other macros i finally found it.

changed

Code: Select all

 /declare tday int outer
to

Code: Select all

 /declare tday float
simple as hell. spent all day and just couldnt figure it out until after i ask for help go figure. sorry for the wasted thread.

caj
a hill giant
a hill giant
Posts: 244
Joined: Tue Sep 12, 2006 9:35 am

Re: getting decimal numbers

Post by caj » Tue Mar 22, 2011 10:58 pm

not sure why i posted help here, must be the cold medicine ive been takeing. this should have been in the vip area. but anyway thank you htw for the quick reply. I did figure out the solution about the same time you posted and as you can see its almost the same solution. I will post the result what i was trying to do on vip.