Hey guys, for a school project, I need to read a .8xp file with PHP. Of course, I can use file_get_contents( but that gives me strings, and I want the hex/decimals into an array. Now the token "Disp " becomes Þ instead of $DE (or 222). Any idea how to do that? Thanks in advance!
PT_ wrote:
Hey guys, for a school project, I need to read a .8xp file with PHP. Of course, I can use file_get_contents( but that gives me strings, and I want the hex/decimals into an array. Now the token "Disp " becomes Þ instead of $DE (or 222). Any idea how to do that? Thanks in advance!
I don't entirely understand your question. Do you want to be able to read tokenized data out of a program file, like being able to get "Disp", or do just want to open it like any other binary file? For the first, this might prove useful: https://github.com/adriweb/tivars_lib
https://ivoah.net
My Calcs: TI-86, TI SR-56, TI-Nspire CX CAS, TI-83+ SE
TI-84+ SE, TI-85, TI-73 Explorer VS, TI-84+ CSE, TI-89 Titanium
My Calcs: TI-86, TI SR-56, TI-Nspire CX CAS, TI-83+ SE
TI-84+ SE, TI-85, TI-73 Explorer VS, TI-84+ CSE, TI-89 Titanium
Indeed my tivars_lib code should help you do that in PHP.
The tests.php file is full of example, but basically, you'd need to do:
Code:
Then the program, as a human-readable string, is in $testPrgmContent.
The tests.php file is full of example, but basically, you'd need to do:
Code:
<?php
include_once "src/autoloader.php";
use tivars\TIVarFile;
$testPrgm = TIVarFile::loadFromFile('the/path/to/your/program.8xp');
$testPrgmContent = $testPrgm->getReadableContent();
Then the program, as a human-readable string, is in $testPrgmContent.
Unfortunately, this is not exactly what I want
Your library converts the input to readable string, which is nice, but when I display $testPrgmContent[0], it displays "F" and I need the first token, which is For(. Still a good library though!
Any other ideas about how to convert the input to tokens (or corresponding hex)? Thanks in advance!
Your library converts the input to readable string, which is nice, but when I display $testPrgmContent[0], it displays "F" and I need the first token, which is For(. Still a good library though!
Any other ideas about how to convert the input to tokens (or corresponding hex)? Thanks in advance!
UPDATE: I found a way to read it, better said, the hex. I got it from this. This is my code:
Code:
Code:
<?php
$handle = @fopen("TEST.8xp", "r");
if ($handle) {
while (!feof($handle)) {
$buffer[] = fgets($handle, 400);
}
fclose($handle);
// $buffer[0][0] = chr(hexdec("FF")); // set the first byte to 0xFF
echo bin2hex($buffer[2][7]);
}
Another option for an open-source TI token manipulation library would be elfprince13's excellent TITokens, which works with many different languages (and can be used for many different purposes, including syntax highlighting, tokenization, etc). Pro-tip from SAX: to get started, execute https://github.com/elfprince13/TITokens/blob/master/build.sh .
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement