Page 1 of 1

proc parameters

Posted: Tue Oct 19, 2021 7:14 am
by John
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

Re: proc parameters

Posted: Mon Oct 25, 2021 5:34 am
by mikemiller
You can do so using the CHAIN statement.

As an example, in example.proc:

Code: Select all

PRINT 'Foo$ is equal to ' & Foo$ & '.'

And then in your calling program:

Code: Select all

0001 let Foo$ = 'bar'
0002 chain 'proc=example.proc', Foo$
Output:
Foo$ is equal to bar.

Re: proc parameters

Posted: Thu Oct 28, 2021 5:45 pm
by Gabriel
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! :)

Re: proc parameters

Posted: Fri Oct 29, 2021 11:25 am
by mikemiller
Just to add onto my prior example, a more realistic approach would be something like this.

ED PROC file:

Code: Select all

execute 'sys "C:\Program Files\NotePad++\NotePad++.exe"  '& SourceFile$ & ' -n' & Line$
Calling program:

Code: Select all

0001 let SourceFile$ = 'lib\myprogram.br.brs'
0002 let Line$ = '153'
0003 chain 'proc=ED', SourceFile$, Line$
This would open up the source file "lib\myprogram.br.brs" in N++ at line number 153.

Re: proc parameters

Posted: Tue Nov 09, 2021 5:48 pm
by gordon
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.