Could any "Lua guys" confirm my thoughts.

Having problems with or questions about SheetCam? Post them here.
Post Reply
mancavedweller
Posts: 161
Joined: Tue Feb 25, 2014 6:53 am

Could any "Lua guys" confirm my thoughts.

Post by mancavedweller »

See the post-processor code line highlighted in red:

function OnInit()

offX = 0
offY = 0
offZ = 0

post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text
post.Text (" (Filename: ", fileName, ")\n")
post.Text (" (Post processor: ", postName, ")\n")
post.Text (" (Date: ", date, ")\n")
if(scale == metric) then
post.Text (" G21 (Units: Metric)\n") --metric mode
else
post.Text (" G20 (Units: Inches)\n") --inch mode
end
post.Text (" F1\n G53 G90 G40\n")
minArcSize = 0.2 --arcs smaller than this are converted to moves
firstRef = refDistance >=0
currentZAxis = " Z"

dist = 9999999
lastz = 0
thcstate = 1
ThcOff()
xPlus = false
yPlus = false
cX = 0
cY = 0
end

My thoughts are that is simply wrong, as ">=" means "is greater than or equal to", and is normally used as a comparative test on a variable.
In this case however, it's attempted use is to define a variable.
Isn't that completely wrong ??
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: Could any "Lua guys" confirm my thoughts.

Post by Les Newell »

The comparison >= returns either true or false. Basically that line is setting the variable 'firstRef' to true if refDistance is greater than zero.
mancavedweller
Posts: 161
Joined: Tue Feb 25, 2014 6:53 am

Re: Could any "Lua guys" confirm my thoughts.

Post by mancavedweller »

Thanks very much Les.

Well, that has taught me something new. I've read a few programming books, videos, etc and never seen that one.

I was quite sure the statement was wrong but something made me ask to confirm. Good job I did :P

I guess I've never thought of comparative statements as "returning" a value of true or false.
I've simply been under the impression that if the comparison is true then.............but never if the comparison returns a VALUE of true or false.

I see it in a whole different light now, and that statement takes on a whole new meaning. Much appreciated.
Post Reply