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

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?


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.

hello @Mike2,

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

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

@anon73440385: 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 @Mike2, greetings to @Mike2 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