Beispiel #1
0
 * https://github.com/adriweb/tivars_lib
 * License: MIT
 */
include_once "src/autoloader.php";
include_once "src/TypeHandlers/TH_0x05.php";
use tivars\TIModel;
use tivars\TIVarFile;
use tivars\TIVarType;
use tivars\TIVarTypes;
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"));
//$newPrgm->setContentFromString("Asm(prgmABCD");
//print_r($newPrgm->getRawContent());
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Real"));
//$newPrgm->setContentFromString("45.2");
//print_r($newPrgm->getRawContent());
$testData = tivars\TypeHandlers\TH_0x05::makeDataFromString("Disp Toto");
$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName("Program"), "Bla", TIModel::createFromName("84+"));
$goodTypeForCalc->setContentFromData($testData);
$goodTypeForCalc->saveVarToFile("/", "trololol");
//try
//{
//$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName('ExactComplexFrac'), 'Bla', TIModel::createFromName('84+'));
//assert(false);
//} catch (Exception $e) {}
//assert(TIVarTypes::getIDFromName("ExactRealPi") === 32);
$testPrgm = TIVarFile::loadFromFile('testData/Program.8xp');
//echo "testPrgm->getHeader()['entries_len'] == " . $testPrgm->getHeader()['entries_len'] . "\n";
//echo "testPrgm->size() - 57 == " . ($testPrgm->size() - 57) . "\n";
//assert($testPrgm->getHeader()['entries_len'] === $testPrgm->size() - 57);
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"));
//$testPrgmcontent = $testPrgm->getReadableContent(['lang' => 'fr']);
Beispiel #2
0
$testPrgm42->setCalcModel(TIModel::createFromName("82"));
$testPrgm42->setContentFromString("");
$testPrgm42->setVarName("Toto");
//$testPrgm42->saveVarToFile("testData", "blablaTOTO_new");
$newReal = TIVarFile::createNew(TIVarType::createFromName("Real"));
$newReal->setContentFromString(".5");
echo "testReal.getReadableContent() : " . $newReal->getReadableContent() . "\n";
print_r($newReal->getRawContent());
$testString = TIVarFile::loadFromFile("testData/String.8xs");
assert($testString->getReadableContent() == "Hello World");
$testEquation = TIVarFile::loadFromFile("testData/Equation_Y1T.8xy");
assert($testEquation->getReadableContent() == "3sin(T)+4");
$testReal = TIVarFile::loadFromFile("testData/Real.8xn");
echo "testReal.getReadableContent() : " . $testReal->getReadableContent() . "\n";
assert($testReal->getReadableContent() == "-42.1337");
$testData = tivars\TypeHandlers\TH_0x05::makeDataFromString("\"<\":Asm(prgmABCD");
$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName("Program"), "Bla", TIModel::createFromName("83PCE"));
$goodTypeForCalc->setContentFromData($testData);
$test = $goodTypeForCalc->getReadableContent();
$goodTypeForCalc->setContentFromString($test);
echo $goodTypeForCalc->getReadableContent() . "\n";
//$goodTypeForCalc->saveVarToFile();
$badTypeForCalc = TIVarFile::createNew(TIVarType::createFromName('ExactComplexFrac'), 'Bla', TIModel::createFromName('83PCE'));
try {
    $goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName('ExactComplexFrac'), 'Bla', TIModel::createFromName('84+'));
    assert(false);
} catch (Exception $e) {
}
assert(TIVarTypes::getIDFromName("ExactRealPi") === 32);
$testPrgm = TIVarFile::loadFromFile('testData/Program.8xp');
echo "testPrgm->getHeader()['entries_len'] == " . $testPrgm->getHeader()['entries_len'] . "\n";