Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Analias on March 17, 2018, 10:20:09 PM

Title: Is there a bug with mc.mcProfileGetDouble()?
Post by: Analias on March 17, 2018, 10:20:09 PM
What am I missing here? I'm trying to use mc.mcProfileGetDouble() and the default value is a fractional value. I get back a numeric value of zero. The API docs claim it should return the existing value or the default value if the property doesn't exist.

Code: [Select]
hgProbing.params = {
   ...
   ['StepOffDistance'] = math.abs (mc.mcProfileGetDouble (inst, 'hgProbing', 'StepOffDistance', 0.5)),
   ...
}

I have to do an explict mcProfileWriteDouble() to get it to work. Now when I do the mcProfileGetDouble () returns the expected value of 0.5.

This looks like a bug with mcProfileGetDouble(). Can anyone confirm?


-Freeman
Title: Re: Is there a bug with mc.mcProfileGetDouble()?
Post by: joeaverage on March 18, 2018, 12:10:58 AM
Hi,
haven't tried it so can't really help, although I have a question.

Is 0 not a value? The way I read it is that if the value does not exist ie null then it would return your default.

Craig
Title: Re: Is there a bug with mc.mcProfileGetDouble()?
Post by: Analias on March 18, 2018, 12:25:10 AM
Is 0 not a value? The way I read it is that if the value does not exist ie null then it would return your default.

Yes in this case 0 is a value, but not the one the API docs suggest should be returned. If you supply 0.5 as the default value, and the Section/Key doesn't exist in the profile, it is suppose to return 0.5 not 0. I deleted the section using mcProfileDeleteSection() to make sure it didn't exist.

Title: Re: Is there a bug with mc.mcProfileGetDouble()?
Post by: joeaverage on March 18, 2018, 12:34:48 AM
Hi,
I haven't encountered that however I haven't tried it either.

Certainly sounds fishy that you can delete a section and yet get a numeric, albeit 0, return.

I have on a few occasions found myself thinking that I've found a Mach4 bug only to be given an explanation as to its behavior and while that may be
quirky its not a fault.

Craig