Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about using arguments in the called function #36

Open
therafman opened this issue May 5, 2014 · 2 comments
Open

Question about using arguments in the called function #36

therafman opened this issue May 5, 2014 · 2 comments

Comments

@therafman
Copy link

Hello,

just wanted to thank you for making bitlash available, I can see it has a lot of potential.
I have a question about using arguments in the called function: I am trying to create a function that passes the pin number to blink an LED.

This function works on the command prompt: function toggle {x = dr(arg(1)); dw(arg(1),!x);}

However I cannot run it in the background, I receive this error message:

run toggle(13),200
-------------------^
unexpected number

I tried passing two arguments including one for a delay like this:
function toggle {x = dr(arg(1)); dw(arg(1),!x); snooze(arg(2));}
but no change...

I tried to look up any info but came up empty. Any ideas?

@billroy
Copy link
Owner

billroy commented May 5, 2014

Hello,

Thanks for your note, and your kind words.

The problem you are running into is caused by the limitation that background macros can’t take arguments.

The workaround is to make a “trampoline function” with no arguments to call your function with arguments, and run the trampoline:

function t13 {toggle(13)}
run t13, 200

Does that help?

-br

On May 4, 2014, at 11:33 PM, therafman notifications@github.com wrote:

Hello,

just wanted to thank you for making bitlash available, I can see it has a lot of potential.
I have a question about using arguments in the called function: I am trying to create a function that passes the pin number to blink an LED. This function works on the command prompt: function toggle {x = dr(arg(1)); dw(arg(1),!x);}
However I cannot run it in the background, I receive this error message:

run toggle(13),200

-------------------^
unexpected number

I tried passing two arguments including one for a delay like this: function toggle {x = dr(arg(1)); dw(arg(1),!x); snooze(arg(2));}
but no change...

I tried to look up any info but came up empty. Any ideas?


Reply to this email directly or view it on GitHub.

@therafman
Copy link
Author

Thank you for the prompt reply Bill.
Unfortunately it looks like it won't work, but that's OK... I was just testing it for an idea I had and I can get around it by offloading that work to the external PC.

Thank you again, ciao for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants