浏览代码

init commit

Noah 4 年之前
父节点
当前提交
e83f1bf16c
共有 2 个文件被更改,包括 45 次插入0 次删除
  1. 16 0
      build-etc/tibasicc
  2. 29 0
      src/quadr.tibasic

+ 16 - 0
build-etc/tibasicc

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# print error message and exit script when no arguments given
+((!$#)) && echo "Error: No filename specified!" && exit 1
+
+# make a temporary directory to run the preprocessor before compiling
+mkdir .preprocessor-temp-dir
+cp "$1" ".preprocessor-temp-dir/$1" 
+sed -i "s/\s*#.*//g; /^$/ d" ".preprocessor-temp-dir/$1"
+
+# run the actual compiler
+wine ~/.winetesting/tibasic-1.4.4/tibasic.exe ".preprocessor-temp-dir/$1" &>/tmp/tibasic-preprocessor.log
+mv .preprocessor-temp-dir/*.8xp .
+
+# remove the temporary directory
+rm -r .preprocessor-temp-dir/

+ 29 - 0
src/quadr.tibasic

@@ -0,0 +1,29 @@
+# this is a program to solve a simple quadratic equation
+# with a (soon) very advanced result presentation
+
+# clear screen
+ClrHome
+
+# get user input
+Input "A= ",A
+Input "B= ",B
+Input "C= ",C
+
+# calculate the solution // todo: 
+(B^2-(4*A*C))->J
+([neg]B+[root]^2(B^2-(4*A*C))/(2*A)->X
+[neg]A->D
+[neg]B->E
+[neg]C->F
+[root]^2(B^2-(4*A*C))->[theta]
+(E-[theta])/(2*A)->M
+(E+[theta])/(2*A)->L
+
+# display the two solutions
+Disp "X1: "
+Disp "X2: "
+Output(4,5,L)
+Output(5,5,M)
+
+# I'll figure out later why I did this 2 years ago
+2*A->A