McBasic™Get McBasic™ ↗
Build 881
Hands-on tutorial · Extensions

Call a packaged BASIC library

Resolve a library reference and call its exported function.

0 Form / control designs1 complete BASIC filesGuided sample project

Keep the package ID and version in the reference consistent with the built archive. The consumer should compile against the public contract rather than a source file copied into its own module list. Preserve the lockfile when collaborating or rebuilding.

Step 1Prepare a safe practice project#

Extract the archive into a new writable folder, separate from your own application. Open MoneyToolsConsumer.mcproj in McBasic™. Keep every declared source, layout, resource and migration file together.

To reconstruct it yourself, create a ConsoleApp project and add the files declared below. In the complete project, follow these steps as a guided rebuild: replace each named source file once and Check after all its procedures are present.

Exact project configuration
MoneyToolsConsumer.mcproj
{
  "schemaVersion": 1,
  "projectId": "dc38d841-2f2b-4acd-aad8-8c83694fa783",
  "name": "MoneyToolsConsumer",
  "kind": "ConsoleApp",
  "language": {
    "dialect": "McBasic1",
    "requireExplicit": true,
    "compare": "Binary",
    "defaultArrayBase": 0
  },
  "forms": [],
  "modules": [
    {
      "name": "Main",
      "path": "Main.bas"
    }
  ],
  "classes": [],
  "tests": [],
  "packages": [
    {
      "id": "com.mcbasic.samples.moneytools",
      "version": "1.0.0"
    }
  ],
  "references": [],
  "resources": [],
  "targets": [
    "osx-arm64"
  ],
  "capabilities": []
}

Step 2Declare the modules and public contract#

This is a nonvisual ConsoleApp project. Add the declared modules and classes; do not create a dummy Form. Public members are its API and Private members are implementation details.

Step 3Connect the events explicitly#

The entry points are callable procedures, not Designer events. Keep their names and signatures exactly as shown in the code.

Step 4Enter the complete behavior#

Open the named source file. Enter declarations first, then every procedure. Expand a procedure for its full body, or copy the complete file. Helpers are required: do not stop after entering the first Click handler.

Main.bas

Enter these declarations at file scope, before the procedures.

Main.bas · declarations
Option Explicit
Sub Main()

Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.

Main.bas · Main
Sub Main()
    Dim total As Currency
    total = MoneyTools.AddCurrency(12.3400@, 0.6600@)
    Debug.Print CStr(total)
End Sub
Copy the complete Main.bas file

Replace the file once; do not append duplicate procedures.

Main.bas
Option Explicit

Sub Main()
    Dim total As Currency
    total = MoneyTools.AddCurrency(12.3400@, 0.6600@)
    Debug.Print CStr(total)
End Sub

Step 5Keep resources and storage reproducible#

No external resource or migration files are declared. Any inline migration, seed data or local JSON is present in the code above. Runtime application data and private preferences are not included in the archive.

Step 6Check, run and test the result#

Save all files and run Check. Resolve diagnostics before Run. Supply the resolved package inputs described in the SDK guide. Developer CLI users can work from the extracted folder:

Use the complete consumer command sequence, including its package options.

Acceptance checklist

  • Build and install the MoneyTools package first.
  • Resolve the consumer reference and run Check.
  • Run the console consumer and inspect the calculated result.

Step 7Make one change and repeat the tests#

Change the inputs, rebuild and verify the result without modifying the library source.

Save a working Git checkpoint first. Change one behavior, Check again and repeat the acceptance checklist. Compare with the downloaded solution if a regression appears.

Source baseline 20f4bfed6b · Build manifest