CASIO BASIC for VS Code (fx-CG10 / fx-CG20 / fx-CG50)
Double-click a calculator .g3m program to read and edit it as normal text.
Ctrl+S saves it straight back to the .g3m. There is no conversion step.
Tested against 75 real programs from an fx-CG20AU. Opening and saving any of
them without changes leaves the program byte-for-byte identical. The
fx-CG50 (incl. fx-CG50AU) uses the same format.
Features
- Double-click
.g3m files to open them as CASIO BASIC text, shown the way the
calculator shows them (→, ≠, ◢, Then, Locate …) and indented by block.
- Save writes the
.g3m. Lines you didn't change keep their exact original
bytes. Changed lines are stored as written.
- New program: right-click a folder → New CASIO BASIC Program.
- Warnings for:
- lines that look right but are stored wrong on the calculator (e.g.
Then
typed as the letters T,h,e,n instead of the Then command). Saving repairs them.
- If/Then without IfEnd, For without Next, While/Do without an end.
- multi-letter variables like
A→AI (the calculator only has A–Z, r, θ).
- characters the calculator can't represent. These block saving, with a message.
- Hover any command to see its opcode. The status bar shows the
.g3m size.
- Completion for all commands, plus
\name symbols: \theta → θ,
\-> → →, \Disp → ◢, \sqrt → √, \<> → ≠.
- Snippets:
if, ife, for, fors, while, do, locate, getkey, input.
Writing code
As you type, these turn into the real symbols (outside strings and comments).
Anything pasted is converted when you save:
| Type |
Gets |
|
Type |
Gets |
-> |
→ |
|
* |
× |
=> |
⇒ |
|
/ |
÷ |
<> or != |
≠ |
|
>= <= |
≥ ≤ |
Backslash menu: type \ to list symbols, with the everyday ones first:
| Symbol |
Type |
|
Symbol |
Type |
→ |
\-> \to |
|
◢ |
\disp |
× |
\* \x \times |
|
⁻ (negative) |
\neg \(-) |
÷ |
\/ \div |
|
√ ² ⁻¹ |
\sqrt \^2 \inv |
≠ ≤ ≥ |
\<> \<= \>= |
|
θ π ⅈ |
\theta \pi \i |
⇒ |
\=> |
|
ᴇ (EXP) |
\E |
Everything else on the calculator is in the same menu under its name (e.g. \Sigma).
Undo (Ctrl+Z) right after a conversion brings back what you typed. Turn
conversion off with the setting casioBasic.autoReplaceSymbols.
- is the subtract key and ⁻ is the (-) key, as on the calculator.
- Inside
"strings", text is literal ("A*B" keeps its asterisk).
- Keywords work with or without their built-in space (
Then, Then ).
r and θ are the variables. P(1-P) means P×(1-P). The probability functions
are spelled ProbP( ProbQ( ProbR( Probt(, and 𝟏𝟎 (\10^x) is the 10ˣ key.
- Indentation is only for reading; it isn't stored on the calculator.
- The first lines
'@name PROG (max 8 characters) and optional '@password X
hold the program's name and password.
Getting programs on and off the calculator
- Connect over USB and choose USB Flash on the calculator.
- Programs are in
@MainMem\PROGRAM on the calculator drive. Double-click one to edit,
or copy .g3m files in or out.
- Eject the drive properly before unplugging, so the calculator reloads its memory.
Install
code --install-extension casio-basic-0.3.0.vsix
Or open this folder in VS Code and press F5 to try it in a development window.
Command line (optional)
node bin/casio-basic.js info <file.g3m>
node bin/casio-basic.js decode <file.g3m|folder> [-o outdir] # to self-contained text
node bin/casio-basic.js encode <file.cbas|folder> [-o outdir]
Development
npm test runs the round trip over the snapshot plus unit tests.
src/tokens.json is generated by tools/build_tokens.py; npm run grammar
regenerates the highlighting.
docs/G3M-FORMAT.md describes the file format.
Limitations
- Only programs are shown as text. Other
.g3m files (lists, matrices, settings)
report "does not contain a CASIO BASIC program".
.g1m/.g2m (fx-9860 family) files aren't opened by double-click; saving always
writes the fx-CG .g3m format.
- Not yet tested by running a saved file on a calculator. Try a small program first.
| |