Acoustic Guitar Body Maker --- Improved Version

This forum is for users to submit their own gadgets to the community
Post Reply
User avatar
sharkcutup
Vectric Wizard
Posts: 3432
Joined: Sat Mar 26, 2016 3:48 pm
Model of CNC Machine: Shark HD3 Pro Extended Bed with Spindle
Location: U.S.A.

Re: Acoustic Guitar Body Maker --- Improved Version

Post by sharkcutup »

adze_cnc wrote:
Wed Nov 20, 2024 7:46 pm
One thing to watch out for is the function ifT(x)

It will behave oddly if presented a non-Boolean value:

Code: Select all

print(ifT("abc")) -- returns: Yes
print(ifT(123.56)) -- returns: Yes
print(ifT(nil)) -- returns: No
You could add...

Code: Select all

assert(type(x) == "boolean", "Argument must be a true or false value.")
...to catch passing non-Boolean values during testing.

You could also use:

Code: Select all

function ifT(x)
  assert(type(x) == "boolean", "Argument must be a true or false value.")
  return x and "yes" or "no"
end
To tighten things up a bit.
Merci, ADZE_CNC! :)

I have entered the tighten things up a bit Option to the Code.

Cheers,
Sharkcutup
V-Carve Pro Tips, Gadget Tips & Videos
YouTube Channel - Sharkcutup CNC
V-Carve Pro 12.013

Post Reply