Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.
La shoutbox n'est pas chargée par défaut pour des raisons de performances. Cliquez pour charger.

Forum Casio - Projets de programmation

Index du Forum » Projets de programmation » Casio CAS format conversion scripts for legacy CFX
Calamari Hors ligne Membre Points: 229 Défis: 0 Message

Casio CAS format conversion scripts for legacy CFX

Posté le 24/10/2022 02:14

The attached Python 3 scripts convert Casio Basic programs to/from the Casio CAS format. This is meant to be used on very old CFX calculators such as the CFX-9800G. CAS files are expected/generated when transferring programs to/from the calculator using the Casio FA-121 software.

First, why did I create these when we can already view and edit CAS files in the FA-121 software? And the answer is: That editor is from 1994 and does not support newer CFX opcodes such as color commands. Additionally, writing code in Windows with a white background is not my preference (although in all honesty I probably would have put up with it). I'm glad I wrote these as I can now develop my programs in Linux using a text editor of my choice, and I can even build the CAS files for my project using a simple Makefile.

For these scripts to be applicable, your calculator's ALPHA key must be to the right of the SHIFT key:

If your ALPHA key is below the SHIFT key, your calculator is too new for these scripts. Behavior is undefined.
There are other types of CAS files (Editor, Function Mem, Matrix, etc), but these scripts only handle the Program type. Behavior when used on non-Program CAS files is undefined.

Convert Program from CAS to TXT
cas2txt FILENAME.cas >FILENAME.txt
A UTF-8 text file will be created containing the program's contents.

If an opcode is not understood it will be output inside curly braces. Example:
Please let me know if you encounter one of these and also what you see on your calculator.

Convert Program from TXT to CAS
txt2cas FILENAME.txt >FILENAME.cas
A Casio CAS file will be created containing the program's contents.

Newline Handling
In a Casio Basic program the ↲ character visually depicts a new line. This might make sense on the small calculator screen, but on a PC, it just adds visual clutter. Therefore, the ↲ character is not included in files generated by cas2txt. The ↲ character is also ignored, if present, when running txt2cas. Instead, each line is assumed to have a newline after it by txt2cas, unless the line ends with ◢ in which case the newline is ignored.

Text Interpretation in txt2cas
There isn't a 1:1 mapping between Casio opcode textual representation and Unicode characters, and some are even visually ambiguous (pop quiz, which is one is Micro rather than Mu: µ or μ). And, some combining-mark characters such as x̄ and x̂ are not supported by all editors or display poorly. Plus, it's annoying to have to constantly copy/paste Unicode characters when trying to write a program. Therefore, a plain text representation is provided for almost all opcodes.

When possible, the plain text representations from https://bible.planet-casio.com/simlo/chm/v20/fxCG20_OPCODES.htm have been implemented. However, that page documents opcodes for much newer calculators than are targeted by these scripts. As a result, some of the legacy CFX opcodes are not defined in that document, some have changed meaning, and a great number of additional opcodes are present there. That said, that page is a good reference for pretty much every opcode you'll encounter when writing a program.

Unicode representations that match those generated by cas2txt are provided. Some alternate plain text representations are also provided, as well as lowercase versions of those whenever possible (notable exceptions: Deg, Gra, and Rad, as their lowercase forms needed to be preserved for plain text alternates to °, ᵍ, and ʳ.

To find a text representation for a certain opcode, use your calculator to create a program containing that opcode and use cas2txt. If it provided a Unicode representation, search txt2cas to see if there is a plain text representation.

Other interpretation features and notes:
• Some special representations are available: ^2 for ², ^-1 for ⁻¹, and 10^ for ⏨. These are aware of the presence of surrounding digits, so for example ^20 will remain ^20 and won't be corrupted as ²0.

• Whitespace (spaces, tabs, etc) will be stripped from the beginning and end of each line. This means you can indent your code (loops, etc) without it affecting the CAS file. Adding some simple indentation improves readability dramatically.

• Spaces outside of comments and strings are removed. Thus, you can write lines such as:
I < 136 => Goto 3

• Blank lines are removed, so you can break your code up into logical sections.

• Doubling the comment character produces an internal-only comment that won't be written to the CAS file. This is useful for documenting your program without bloating the CAS size. These internal comments can also be placed at the end of a line. Examples:
'' Shuffle deck
Z[I] -> Z[13I-540] '' 45+13*(I-45)

• The character "-" always produces a subtraction opcode. However, I've found that's usually adequate as the calculator tolerates using subtraction in nearly all situations. These definitely work: -5, -(2+3), 2--3. However, if necessary, you can use (-) or the Unicode ⁻ to force a negative sign.

• Any final newline in the file is omitted.

LienAjouter une imageAjouter une vidéoAjouter un lien vers un profilAjouter du codeCiterAjouter un spoiler(texte affichable/masquable par un clic)Ajouter une barre de progressionItaliqueGrasSoulignéAfficher du texte barréCentréJustifiéPlus petitPlus grandPlus de smileys !
Cliquez pour épingler Cliquez pour détacher Cliquez pour fermer
Alignement de l'image: Redimensionnement de l'image (en pixel):
Afficher la liste des membres
:bow: :cool: :good: :love: ^^
:omg: :fusil: :aie: :argh: :mdr:
:boulet2: :thx: :champ: :whistle: :bounce:
 :)  ;)  :D  :p
 :lol:  8)  :(  :@
 0_0  :oops:  :grr:  :E
 :O  :sry:  :mmm:  :waza:
 :'(  :here:  ^^  >:)

Σ π θ ± α β γ δ Δ σ λ
Veuillez donner la réponse en chiffre
Vous devez activer le Javascript dans votre navigateur pour pouvoir valider ce formulaire.

Si vous n'avez pas volontairement désactivé cette fonctionnalité de votre navigateur, il s'agit probablement d'un bug : contactez l'équipe de Planète Casio.

Planète Casio v4.3 © créé par Neuronix et Muelsaco 2004 - 2024 | Il y a 43 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements

Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd