Browser capabilities and permissions
Understand how SCAN, GPS, camera, sound, files, and network access depend on browser capabilities and permissions in Cortex BASIC.
Cortex BASIC reference · language features and browser requirements.
The language stays familiar; the platform can differ
DEVICEAVAILABLE(name$) returns -1 when an implemented feature can be attempted in this browser, or 0 when unavailable, denied, insecure or unsupported. Names are case-insensitive. Checks do not prompt for access. Permission may still be requested by the actual operation, and hardware or format failures remain possible. Open More → Settings for current permission details, or Projects → Device Check for a runnable BASIC example.
PRINT DEVICEAVAILABLE("MICROPHONE") checks recording support. IMAGE, AUDIO, VIDEO, MICROPHONE and KEYBOARD are implemented. CAMERA, PHOTO, SCAN and FLASH are implemented with browser conditions. PHOTO and image scanning work on HTTP; live camera and flashlight require HTTPS or localhost. GPS, motion sensors, battery/device/screen information, speech, raw touch and controllers are implemented with browser and permission conditions. Try Projects → Device Playground.
What to expect in your browser
Cortex checks browser features directly. It does not decide what works from a browser name. More → Settings → Browser capabilities and permissions shows this browser's current state. Check again after changing a permission in your browser settings. Checking never opens a camera, reads the clipboard, requests your location or asks for notification permission.
Automated checks cover the WebKit browser engine with phone, tablet and desktop layouts, Chromium with phone and desktop layouts, and desktop Firefox. These checks exercise BASIC execution and the shared browser adapters. Emulated phone layouts do not verify physical cameras, sensors, speakers, keyboards or Home Screen installation. Branded Safari and Edge need their own device checks; a shared engine is not certification.
- Local programs and projects
- The same BASIC runtime, project storage, image processing, JSON/CSV and SQLite run locally. Saving depends on browser storage being available. Private browsing and clearing site data can remove projects; keep exported backups.
- Camera, microphone and location
- Live access requires HTTPS or localhost, exposed browser APIs and permission. The private HTTP LAN address cannot provide secure-only features. A photo selected from Files and a QR code in a project image can still work without a live camera.
- Motion, compass, battery and controllers
- Support varies by browser and physical hardware. A visible API permits an attempt; it does not prove a reading or connected device exists. Motion can require a Continue tap. Missing battery or torch APIs report unavailable. Touch support includes pointer input and does not prove a touchscreen is present.
- Speech and media
- Playback can require a tap; voices, recording encoders and image/video formats vary. Speech recognition may use a browser provider's network service and explains this before starting.
- Clipboard, sharing and notifications
- These depend on HTTPS, browser support and a deliberate action. Some browsers cannot report clipboard permission in advance. A known notification denial is shown immediately. Sharing may offer a download fallback; notifications also have an in-app confirmation and no background scheduler.
- Offline and installation
- More → Offline & updates reports actual readiness. Installation may use a browser prompt or the manual Home Screen instructions. Save and close all Cortex tabs to activate an update. Git, AI, web requests and browser-provider services still need a connection.
Available means an attempt is possible. Permission required or permission unknown does not mean access is granted. A browser policy may block a feature even when an API exists; the actual operation still enforces browser permissions and reports failures.
Capture photos and scan codes
SCAN code$ opens live scanning or image selection; SCAN code$, "Images/Code.png" decodes project bytes locally. A chosen image with no code returns an empty string. Live scanning waits for a code or cancellation/timeout. Decoded text is never opened or executed automatically.
CAMERA picture& takes a photo after tapping Start camera and Take photo. Add , "front" to prefer the front camera. PHOTO picture& selects an image. Both return normal image handles: use SAVEIMAGE "Images/MyPhoto.png", picture& to save and FREEIMAGE picture& when finished. Raster input is limited to 25 MiB and images are scaled to at most 1600 pixels on the longest side.
FLASHLIGHT ON requests a supported camera torch. FLASHLIGHT OFF, Stop, page hiding, another acquisition or Editor completion releases it. The acquired camera must expose torch capability and confirm that the torch is on; otherwise Cortex reports it unavailable. Scanning tries native detection when present and falls back to the local decoder, including rotated barcodes. The acquisition deadline is two minutes. Try Projects → Camera and Codes for an original runnable example.
Location, sensors, touch and speech
Projects → Device Playground has short tests for each hardware family. GPS lat#, lon# reads one location and releases tracking; optional outputs add altitude, accuracy, travel heading and speed. Use DOUBLE destinations for location precision. Unknown altitude is -999999; unknown heading/speed is -1. Location is supplied by the browser and may use its network provider.
ACCELEROMETER x,y,z reads acceleration excluding gravity in m/s²; GYROSCOPE a,b,g reads degrees/second. MOTION a,b,g reads orientation angles; COMPASS heading requires a north-referenced reading. Permission may need a Continue tap. Missing readings are reported honestly; sensors time out after eight seconds.
BATTERY percent,charging%, DEVICEINFO$("LANGUAGE") and SCREENINFO("WIDTH") expose browser information. Battery support varies; device descriptions may be generic. TOUCH x,y,down%,gesture$ polls BASIC graphics-canvas coordinates and gestures. GAMEPAD(0,"CONNECTED") checks a controller; axis/button queries take a control index. Press a physical controller button to expose it to the browser. UI BUTTON remains the BASIC-owned way to create virtual controls.
SPEAK "Hello" waits for browser speech; LISTEN words$ recognizes one phrase. Both support an optional language tag. Speech recognition may send audio to the browser provider; its activation dialog explains this before starting. VIBRATE 200 requests a short vibration where supported. Cancel/Stop, page hiding and completion release hardware resources. GPS and speech have 30-second operation deadlines. HELP GPS, SENSOR, BATTERY, SCREENINFO, DEVICEINFO$, TOUCH, GAMEPAD, SPEAK, LISTEN and VIBRATE document the full signatures.
Features depend on what the browser exposes
The native inventory includes SCAN for QR/barcodes, GPS, camera/photo input, flashlight, haptics, motion sensors, device information, speech, touch, and controllers. On the web, support may depend on the browser, device, secure context, permissions, or a user gesture. Flashlight must report unavailable when torch control is not exposed.
An unavailable device is not an empty result
- Permission denied
- The user or browser refused access.
- Cancelled
- The user or program stopped the operation.
- Unavailable
- The required browser or hardware capability is absent.
- Insecure context
- The page does not meet the browser’s secure-access requirements.
- Timeout
- The operation did not finish within its allowed time.
Device framework errors use ERR 1010 (unavailable), 1011 (denied), 1012 (cancelled operation), 1013 (insecure context), 1014 (timeout), and 1015 (failed). ON ERROR can handle these errors. A known unsupported/denied/insecure capability normally returns 0 from DEVICEAVAILABLE; a failed or timed-out check raises an error. Stop aborts the run rather than resuming its error handler. Existing AUDIO RECORD errors remain 1002–1007 for compatibility. Unsupported permission queries are shown as unknown, and permission is checked again on each request.
Utility Workshop
Projects → Utility Workshop explores Unicode/UTF-8, scalar LIST/MAP/SET collections, bounded regular expressions, time zones, timers, SHA-256 and ZIP files. Every action and control is BASIC source on one program screen. Use HELP UTILITIES, COLLECTIONS, DATES, CRYPTO, ZIP and BROWSER in Terminal for the command signatures and limits.
PRINT ULEN("Hello 😀")
PRINT DATEFORMAT$("2026-03-08T07:30:00Z", "America/New_York")
l& = LISTNEW
LIST ADD l&, "Cortex"
PRINT LISTGET$(l&, 1)
LIST FREE l&CLIPBOARD$, CLIPBOARD WRITE, NOTIFY and FILE SHARE use explicit browser gestures and permissions. DOCUMENT VIEW renders project text, a Markdown subset, isolated HTML or a conditional PDF view with Download fallback. APP OPENURL accepts absolute HTTPS URLs; APPQUERY$ only reads explicit basic_ parameters. NETWORKONLINE is a browser hint. Regex and ZIP run in disposable offline Workers with time and size limits. SHA/HMAC require HTTPS or localhost. CONFIG values are non-secret project assets included in backups; BASIC cannot access IDE credentials.
WebSocket messages from BASIC
Projects → Socket Echo demonstrates a real connection to a public echo service, with every button and action written in BASIC. Use example data only. Connect, Send text, Send file, Save reply and Disconnect let you explore text and binary messages together on the program screen.
h&=WSOPEN("wss://echo.websocket.org")
WS SEND h&, "Hello from BASIC!"
IF WSRECEIVE(h&,5000) THEN PRINT WSMESSAGE$(h&)
WS CLOSE h&
WS FORGET h&WSRECEIVE returns -1 for one message, including an empty message, or 0 on timeout; use a timeout of 0 to poll. WSMESSAGETYPE$, WSBYTES, WSSTATE$, WSPENDING, WSBUFFERED, WSPROTOCOL$, WSCODE and WSREASON$ inspect the connection or last reply. WS SENDFILE sends project bytes; WS SAVE saves the last reply without changing its bytes. HELP WS lists signatures, limits and errors.
Terminal connections persist between commands; Stop, reset, project changes and Editor completion close them. Reconnect explicitly with WSOPEN; there is no automatic replay. WSS uses browser TLS, Origin and cookie rules, and offers no custom handshake headers. The public server may send a welcome message before the echo. REST/HTTP remains subject to CORS; browser storage remains subject to quotas and eviction.