#Part 4. Runtime, Files, And UI
#Part 4 Section 1. Runtime Launch
Every .cba, .exe, .dll, and Linux beta package goes through the Runtime package screen before user code starts. The screen is mandatory always-on Runtime behavior. App source cannot remove it, and compiler flags cannot disable it.
If the package fails before your first line runs, check package integrity, missing runtime files, license status, and asset packaging before debugging app logic.
#Part 4 Section 2. Saving To .cb
Use CB-Storage for ClosedBit save files.
library CB-Storage
fn main() {
u256 coins = 1250
CB-Storage.write_text("player.cb", to_string(coins))
string raw = CB-Storage.read_text_or("player.cb", "0")
u256 loaded = parse_u256_or(raw, 0)
println("Loaded coins:", loaded)
}
Plain text files are fine for logs or simple exports. .cb is the right format when ClosedBit owns the data.
#Part 4 Section 3. Assets And HTML UI
Use CB-AssetLoader for images, models, fonts, audio, video, shaders, and binary bundles.
library CB-AssetLoader
fn main() {
asset logo = CB-AssetLoader.load("assets/logo.png")
println("Loaded:", logo.name)
}
Use CB-UI when the app has an HTML interface. Put ui.html beside the .cbp source or in the project UI folder.
library CB-UI
fn main() {
CB-UI.html_file("ui.html")
}
Keep layout in HTML/CSS. Keep package logic, saves, validation, and error handling in CBP.
