0

I am using a .dll file methods in mapbasic

declare method openmultiplefilesdlg Class "mbextensions",lib "mbextensiondlgs.dll" 
   (declaration variable) as string

but it shows error:

  1. Found [method] while searching for [sub]

and for function declaration

declare function splitline(byval input as string, byval unit_id as integer) as integer

it shows error:

Expecting sub or function

3
  • It would be helpful to post the relevant sections of code that are causing the errors.
    – T_Bacon
    Commented Jun 27, 2016 at 8:05
  • Although, there is one thing you can check. The DLL file (mbextensiondlgs.dll) must be in the same folder as your MBX.
    – T_Bacon
    Commented Jun 27, 2016 at 8:07
  • Make sure you MapBasic version is newer than 9.5 as that's when we started supporting the Declare Method statement. Commented Jun 27, 2016 at 8:50

1 Answer 1

1

The syntax of the Declare Method statement looks like this:

Declare Method fname 
   Class "class_name" Lib "assembly_name"
   [ Alias function_alias ]  
   ( [ [ ByVal ] parameter As var_type ] 
   [, [ ByVal ] parameter As var_type... ] ) [ As return_type ]

Your statement has a few issues: 1. There's a comma after the class name 2. Your parameter statement is missing some declarations

Try changing it to something along these lines:

Declare Method openmultiplefilesdlg
    Class "mbextensions" Lib "mbextensiondlgs.dll" 
    (ByVal sVariableName As Char) As String

I have used sVariableName but you can use almost any name you want.

Also note that I have declared it as a Char type. It must match the declaration of the .NET method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.