help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using function arguments


From: uzibalqa
Subject: Using function arguments
Date: Wed, 05 Apr 2023 20:41:31 +0000


I am having difficulties understanding how to use gawk function arguments.
Customarily, arguments define variables that are local to the function.

But can arguments be used as input that the function can use

As example

function densel(class,   loc) {
 if (class == 1) { print "Class is 1" }
 if (class == 2) { print "Class is 2" }
 loc = 8
 }

BEGIN {
  class=2
  densel(class)
}

Then there is option of using "return class" which can actually return a value 
by calling

x=densel(class)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]