Argument is not optional

I keep getting the error “Argument is not optional” when running the following

REM  *****  BASIC  *****

Sub Main
    Call nRight(5)
End Sub

Sub nRight(n as Integer)
    print "n = ",n
End Sub

What am I doing wrong?

Thanks

Bo B

1 Like

When you run, take care what you run: i.e., where the cursor is.

1 Like

AOO Basic debugger always runs the first Sub / Function of the module if you start with a step. Recent LibO Basic debugger starts the routine where the cursor is in.

1 Like

For readers’ convenience I just formatted the code as code instead of flow text by properly indenting all with 4 spaces.

You will get that error if your insertion point is within Sub nRight when you run the macro.

To avoid the error, position your insertion point within Sub Main before you run the macro, e.g. by clicking within the line ‘Call nRight(5)’.

1 Like