Community discussions

MikroTik App
 
rileonar
just joined
Topic Author
Posts: 24
Joined: Wed Oct 12, 2005 11:22 am

How to pass parameters to a function

Tue Apr 20, 2010 5:31 pm

Hi,

does anyone know how to pass parameters to a function?

I'd like to write a single custom function (e.g.: disk_free_space) and pass to it a parameter, in order to use it into different probes using different values:

a) Probe: server_disk_warning
disk_free_space(2000)

b) Probe: server_disk_alert
disk_free_space(500)

In probe a) I would set the limit threshold to 2000 MB, in probe b) to 500.

Does anybody know if that's possible and eventually some sample to share the syntax to use into the function?

TKS.
 
User avatar
gsandul
Member Candidate
Member Candidate
Posts: 154
Joined: Mon Oct 19, 2009 1:42 pm

Re: How to pass parameters to a function

Wed Apr 21, 2010 11:51 am

Currently there is no way to pass params to function.
 
rileonar
just joined
Topic Author
Posts: 24
Joined: Wed Oct 12, 2005 11:22 am

Re: How to pass parameters to a function

Thu Apr 22, 2010 3:37 pm

Currently there is no way to pass params to function.
Thanks for your answer. :(

I wonder how can I avoid writing hundreds of functions and probes, all identical except for silly parameters like disk label (C, D, /var....), threshold (100, 1000....) and so on.

Does anybody have ideas?

Many thanks in advance.
 
User avatar
znet
Member Candidate
Member Candidate
Posts: 134
Joined: Mon Jul 24, 2006 8:07 pm
Location: Houston, Texas

Re: How to pass parameters to a function

Mon Apr 26, 2010 6:56 pm

How about writing a simple 'daemon' script running on the device that creates variables accessible via ros_command?
 
User avatar
alangregory
just joined
Posts: 9
Joined: Wed May 25, 2011 2:54 pm

Re: How to pass parameters to a function

Mon Sep 11, 2017 8:21 pm

Any news about this feature ?
 
User avatar
geoffsmith31
Member Candidate
Member Candidate
Posts: 153
Joined: Fri Nov 05, 2010 6:08 am
Location: Toowoomba, Australia

Re: How to pass parameters to a function

Wed Oct 25, 2017 8:33 am

I'm also keen to be able to pass parameters into a function that I have written. It seems that this should be possible as many of the built-in functions can accept input parameters. Just that this capability is not exposed (or not documented) for user functions.
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 171
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: How to pass parameters to a function

Wed Oct 25, 2017 10:40 am

Starting from 6.2 ROS supports passing arguments to custom functions:
https://wiki.mikrotik.com/wiki/Manual:S ... #Functions

Also global variables can be used to pass parameters.
 
User avatar
geoffsmith31
Member Candidate
Member Candidate
Posts: 153
Joined: Fri Nov 05, 2010 6:08 am
Location: Toowoomba, Australia

Re: How to pass parameters to a function

Thu Oct 26, 2017 2:44 am

Post by BlackVS » 25 Oct 2017 17:40

Starting from 6.2 ROS supports passing arguments to custom functions:
https://wiki.mikrotik.com/wiki/Manual:S ... #Functions

Also global variables can be used to pass parameters.
I think what you are referring to here is ROS functions - Not Dude functions. If I'm wrong, can you please advise how to pass a parameter into a user created Dude function?
 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 1942
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: How to pass parameters to a function

Sat Dec 01, 2018 10:28 pm

Any news about this feature ?
Bump
MTCNA, MTCTCE, MTCRE & MTCINE
 
User avatar
teslasystems
just joined
Posts: 16
Joined: Sun Aug 09, 2015 3:00 pm

Re: How to pass parameters to a function

Sun May 17, 2020 12:00 pm

This topic is already 10 years old and nothing done. Very bad :(

Who is online

Users browsing this forum: No registered users and 23 guests