Package a reusable BASIC library
Export a small calculation as a library API.
Only the public calculation is part of the consumer contract; Normalize remains private. Use a numeric type appropriate for the calculation and keep the return type explicit. Building a package and certifying it are separate gates; a certification self-test is required for the latter.
Step 1Prepare a safe practice project#
Extract the archive into a new writable folder, separate from your own application. Open MoneyTools.mcproj in McBasic™. Keep every declared source, layout, resource and migration file together.
To reconstruct it yourself, create a Library 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
{
"schemaVersion": 1,
"projectId": "3cc9b1b3-5f60-4d49-a3fc-0a6b9cc7c9a8",
"name": "MoneyTools",
"kind": "Library",
"language": {
"dialect": "McBasic1",
"requireExplicit": true,
"compare": "Binary",
"defaultArrayBase": 0
},
"package": {
"packageId": "com.mcbasic.samples.moneytools",
"version": "1.0.0",
"minimumMcBasicVersion": "0.1.0",
"vendor": "McBasic Samples",
"description": "Typed currency helpers for the McBasic package example.",
"assemblyPath": "lib/net10.0/MoneyTools.dll",
"licenseSpdx": "MIT",
"licensePath": "licenses/LICENSE.txt"
},
"forms": [],
"modules": [
{
"name": "MoneyTools",
"path": "MoneyTools.bas"
}
],
"classes": [],
"tests": [],
"references": [],
"resources": [],
"targets": [
"osx-arm64"
],
"capabilities": []
}Step 2Declare the modules and public contract#
This is a nonvisual Library 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.
MoneyTools.bas
Enter these declarations at file scope, before the procedures.
Option ExplicitPublic Function AddCurrency(ByVal amount As Currency, ByVal increment As Currency) As Currency
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Public Function AddCurrency(ByVal amount As Currency, ByVal increment As Currency) As Currency
AddCurrency = amount + increment
End FunctionPrivate Function Normalize(ByVal amount As Long) As Long
Enter this helper in the named source file, outside every other procedure. Its callers are included in the same project.
Private Function Normalize(ByVal amount As Long) As Long
Normalize = amount
End FunctionCopy the complete MoneyTools.bas file
Replace the file once; do not append duplicate procedures.
Option Explicit
Public Function AddCurrency(ByVal amount As Currency, ByVal increment As Currency) As Currency
AddCurrency = amount + increment
End Function
Private Function Normalize(ByVal amount As Long) As Long
Normalize = amount
End FunctionStep 5Keep resources and storage reproducible#
Keep the following files at their declared relative paths. Apply migrations before the first query. Media and report resources must travel with the build.
| File | Purpose |
|---|---|
licenses/LICENSE.txt | Bundled asset / license |
Step 6Check, run and test the result#
Save all files and run Check. Resolve diagnostics before Run. Developer CLI users can work from the extracted folder:
mcbasic check MoneyTools.mcproj
mcbasic package build MoneyTools.mcproj --rid osx-arm64Acceptance checklist
- Check the library and build a package.
- Inspect the public API metadata for AddCurrency.
- Verify the private helper is not exposed as a consumer API.
Step 7Make one change and repeat the tests#
Add the required public McBasicPluginSelfTest function before attempting library certification.
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.
20f4bfed6b · Build manifest