Is there a way to make a proc so that it can take parameters?
Here's what I'm thinking:
Currently I use a PROC ED from the br console to launch the associated .br.brs file in my preferred development program (n++). This has worked great for years now. I would like to be able to pass a line number so the ED proc file could open n++ on that line of the file. The only problem is I've never added an optional parameter to a proc and I'm not sure if it can be done.
Have you made a proc with an optional parameter? If so, how? And, would you mind sharing a small example?
John
proc parameters
Moderators: Susan Smith, admin, Gabriel
-
- Posts: 12
- Joined: Wed Mar 17, 2021 6:01 am
Re: proc parameters
You can do so using the CHAIN statement.
As an example, in example.proc:
And then in your calling program:
Output:
As an example, in example.proc:
Code: Select all
PRINT 'Foo$ is equal to ' & Foo$ & '.'
Code: Select all
0001 let Foo$ = 'bar'
0002 chain 'proc=example.proc', Foo$
Foo$ is equal to bar.
Re: proc parameters
There is a way to do it in procfiles too, but its a little tricky. Mikes technique might be more straight forward.
Maybe someone remembers it..
But it was something like you have an INPUT VAR1$, VAR2$ kind of statement in the beginning of the proc file. And then you call it but you redirect the parameters into it .. like you save the parameters in a display file with something like PRINT #1: "Value1", "Value2" and then you call the proc with <displayfile.txt
Does this ring a bell for anyone else?
At any rate, even best case thats still more complicated than Mikes solution so it probably doesn't matter if anyone remembers it or not!
Maybe someone remembers it..
But it was something like you have an INPUT VAR1$, VAR2$ kind of statement in the beginning of the proc file. And then you call it but you redirect the parameters into it .. like you save the parameters in a display file with something like PRINT #1: "Value1", "Value2" and then you call the proc with <displayfile.txt
Does this ring a bell for anyone else?
At any rate, even best case thats still more complicated than Mikes solution so it probably doesn't matter if anyone remembers it or not!

-
- Posts: 12
- Joined: Wed Mar 17, 2021 6:01 am
Re: proc parameters
Just to add onto my prior example, a more realistic approach would be something like this.
ED PROC file:
Calling program:
This would open up the source file "lib\myprogram.br.brs" in N++ at line number 153.
ED PROC file:
Code: Select all
execute 'sys "C:\Program Files\NotePad++\NotePad++.exe" '& SourceFile$ & ' -n' & Line$
Code: Select all
0001 let SourceFile$ = 'lib\myprogram.br.brs'
0002 let Line$ = '153'
0003 chain 'proc=ED', SourceFile$, Line$
Re: proc parameters
I have the impression that John uses the PROC ED command to work around his preference to avoid using the EDITOR config statement because the EDIT command itself responds to a simple E command which can be accidently entered.
I also have the impression that John wants to be able to call N++ from the console to edit the current program and he has ED set to reference OS_FILENAME$(PROGRAM$) to identify the current program.
He just wants to optionally pass a line number as in PROC ED 12345. Not write a short program each time he calls N++. John it would have been good to attach your current ED file to your original post.
I suggest that an alternate (modified) ED proc (e.g. EDL) be used to simply prompt for a line number as in "LINPUT LN$" and extending the call to N++ with &" "&LN$.
John if I am off base on this please elaborate.
I also have the impression that John wants to be able to call N++ from the console to edit the current program and he has ED set to reference OS_FILENAME$(PROGRAM$) to identify the current program.
He just wants to optionally pass a line number as in PROC ED 12345. Not write a short program each time he calls N++. John it would have been good to attach your current ED file to your original post.
I suggest that an alternate (modified) ED proc (e.g. EDL) be used to simply prompt for a line number as in "LINPUT LN$" and extending the call to N++ with &" "&LN$.
John if I am off base on this please elaborate.