How to include function library file? 
Author Message
 How to include function library file?

I like to set up awk programs in their own file, e.g.

% head test.awk
#!/usr/local/bin/mawk -f
<program here>

I can run the above program like an executable, w/o specifying the
awk interpreter explicitly on the command:

% test.awk file-input

I also have a file containing various awk functions; call it
/usr/local/lib/funcs.awk.

Is there a way to tell test.awk to use the function library file, not
using the command line?  I.e. something like

% head test.awk
#!/usr/local/bin/mawk -f /usr/local/lib/funcs.awk -f
<program here>

(I tried the above, it didn't work).  I'd rather not use this, which
does work:

mawk -f /usr/local/lib/funcs.awk -f test.awk file-input
--
Ralph Finch, Senior Engineer, W.R.      Tel.    916-653-8268
Delta Modeling Section                  Fax.    916-653-6077

1416 Ninth St, Sacramento, CA 95814     finger for PGP public key



Mon, 03 Apr 2000 03:00:00 GMT  
 How to include function library file?

If you're using GAWK then you could use the AWKPATH environment variable
but that still doesn't get around the multiple -f problem. But what I think
you're asking for is the ability to include a file like C

#include foo.awk

There's a shell script igawk that adds this facility...

Hope this helps...



Quote:
> I like to set up awk programs in their own file, e.g.

> % head test.awk
> #!/usr/local/bin/mawk -f
> <program here>

> I can run the above program like an executable, w/o specifying the
> awk interpreter explicitly on the command:

> % test.awk file-input

> I also have a file containing various awk functions; call it
> /usr/local/lib/funcs.awk.

> Is there a way to tell test.awk to use the function library file, not
> using the command line?  I.e. something like

> % head test.awk
> #!/usr/local/bin/mawk -f /usr/local/lib/funcs.awk -f
> <program here>

> (I tried the above, it didn't work).  I'd rather not use this, which
> does work:

> mawk -f /usr/local/lib/funcs.awk -f test.awk file-input
> --
> Ralph Finch, Senior Engineer, W.R. Tel.    916-653-8268
> Delta Modeling Section                     Fax.    916-653-6077

> 1416 Ninth St, Sacramento, CA 95814        finger for PGP public key



Thu, 06 Apr 2000 03:00:00 GMT  
 How to include function library file?



Quote:

>% head test.awk
>#!/usr/local/bin/mawk -f /usr/local/lib/funcs.awk -f
><program here>

>(I tried the above, it didn't work).  I'd rather not use this, which
>does work:

>mawk -f /usr/local/lib/funcs.awk -f test.awk file-input

You need to make the file executable :

chmod +x test.awk
--
Adam Lovick



Thu, 06 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Library files (lib) and their includes (inc)

2. Call Library Function - Function not found in library

3. msvcrt.dll import library and include files.

4. openGL includes/library files

5. 2003: Including file functions (prototyping problem)

6. integer function with generic include file definition

7. INCLUDE file to declare functions ?

8. function running from include file?

9. including functions from external files?

10. How to include functions from other files?

11. including preprocessor directives in included file

12. call library function- wrong file path

 

 
Powered by phpBB® Forum Software