Ask Your Question
0

is there a way to 'debug' macro functions which use parameters?

asked 2020-07-23 09:15:12 +0200

newbie-02 gravatar image

hi @all,

sorry if i'm in any error or use the wrong wording ... newbie ...

and sorry if it's a silly question, may be i'm just carrying a board ... same reason ...

in calc you can define 'sub'-s and 'function'-s, of which the first do their job when 'called' and have to have the access to needed data coded within themself, while 'function'-s are used in cell-formulas, start without a special call, and may get values (parameters?) passed from that formula - e.g. "=testfunction(A1; 3; B2)",

difficulty: if a 'sub' doesn't work or give error or wrong results you can trace through it in the basic-IDE? (tools-macros-edit macro) by repeatedly pressing F8 and observe reactions and values step by step, but if you try the same with a function you'll get an error message ('Basic runtime error: Argument is not optional') once the function first accesses one of the parameters, thus debugging is blocked,

is there any way to get over this hurdle?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2020-07-23 09:32:37 +0200

Yes.

One way is to invoke it from Calc properly; just put breakpoints in Basic IDE before you use the function in Calc. As soon as Calc runs the function (with arguments), you may step over the Basic code.

Another is creating a helper sub in Basic, that would call the needed function, and pass required parameters. But then you will see the parameters from the helper, bot necessarily same type as Calc would pass.

Yet other if to change function to treat its arguments as optional ... but that's possibly even less wanted in your case.

edit flag offensive delete link more

Comments

hello @Mike,

thanks, the first proposal works, stops at the declaration of the function rather then at the breakpoint, but works, :-)

newbie-02 gravatar imagenewbie-02 ( 2020-07-23 12:21:31 +0200 )edit

@newbie-02: just a hint - referencing @Mike (id 198) references another user than using @Mike Kaganski (id 5801).

Opaque gravatar imageOpaque ( 2020-07-23 12:32:11 +0200 )edit

@Opaque: thanks for that hint, my fault,

i'm doing as plenty other users - trial and error instead of first 'rtfm' - that's bad behaviour on one hand, but first studying everything about a site before using it wouldn't work either because of my 'limited lifetime' ...

it's similar for coding ... if! a programmer would have studied everything about e.g. C++ before! trying it in the real world there would be much less errors in programs, at least because much less programs are written as most 'students' would die before start coding ...

thus: sorry to @Mike, greetings to @Mike Kaganski (didn't even know that references with spaces work, didn't even know it's distinct 'references' but thought that it was simply a highlighting of an identifier that you have chosen for yourself ),

and stays cheerful and healthy, we are living in difficult times

newbie-02 gravatar imagenewbie-02 ( 2020-07-24 06:36:31 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-23 09:15:12 +0200

Seen: 206 times

Last updated: Jul 23 '20