User Tools

Site Tools


Sidebar

Home



G-Code


About

  Order of execution
  Parameters

G-Codes

M-Codes

Other Codes

O-Words

Comments

Functions

  abs[]
  acos[]
  active[]
  and[]
  asin[]
  atan2[]
  atan[]
  bin[]
  ceil[]
  chr[]
  cos[]
  datetime[]
  day[]
  dec[]
  defnz[]
  def[]
  deg2rad[]
  exists[]
  exp10[]
  exp2[]
  expr[][]
  exp[]
  e[]
  fix[]
  floor[]
  froms16[]
  froms32[]
  fromu16[]
  fromu32[]
  fup[]
  hex[]
  hour[]
  inc[]
  land[]
  lnand[]
  lnor[]
  lnot[]
  log10[]
  log2[]
  log[]
  lor[]
  lxnor[]
  lxor[]
  max3[]
  max[]
  millisec[]
  min3[]
  minute[]
  min[]
  mmtounit[]
  month[]
  nand[]
  nan[]
  nop[][]
  nor[]
  notexists[]
  not[]
  or[]
  pi[]
  pow[]
  rad2deg[]
  rand[]
  rounddec[]
  roundup[]
  round[]
  s16[]
  s32[]
  s8[]
  second[]
  shl[]
  shr[]
  sin[]
  sqrt[]
  sqr[]
  tan[]
  tomachine[]
  tos16[]
  tos32[]
  tou16[]
  tou32[]
  towork[]
  trunc[]
  u16[]
  u32[]
  u8[]
  unittomm[]
  xnor[]
  xor[]
  year[]

Operators

Macros

gcode:functions:func-defnz

defnz

Set default value.

Returns val if val exists and is not zero.
Returns def if val does not exist or is zero.

Syntax

defnz[val, def]

Parameters

val Number to be checked it it exists or is zero.
def Number to be returned if val does not exist or is zero.
Return Value val if it exists and is not zero, otherwise def.

Examples

#<result> = defnz[#<val>, 11]
(print,#<result>)

result: 11


#<val> = 99
#<result> = defnz[#<val>, 11]
(print,#<result>)

result: 99


#<val> = 0
#<result> = defnz[#<val>, 11]
(print,#<result>)

result: 11


#<val> = nan[]
#<result> = defnz[#<val>, 11]
(print,#<result>)

result: 11

See also

gcode/functions/func-defnz.txt · Last modified: 2023/01/25 10:18 by 127.0.0.1

Page Tools