GL1TCH3D

Broken supercalc with graph

Aug 14th, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 11.75 KB | None | 0 0
  1. @echo off
  2. mode 70,40
  3. color 0f
  4. title Calculator by GL1TCH3D
  5. set graph=0
  6. set a=0
  7. set x=0
  8. set blehs=0
  9. for /l %%E in (1,1,9) do (
  10. set ans%%E=0
  11. set answer%%E=0
  12. )
  13. setlocal enabledelayedexpansion
  14. :top
  15. cls
  16. echo Type "help" for more information.
  17. echo Type "functions" to input functions.
  18. echo Type "options" to change settings.
  19. echo.
  20. echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  21. echo º  Index of Symbols: º
  22. echo º * = Multiplication º
  23. echo º + = Addition       º
  24. echo º - = Subtration     º
  25. echo º / = Division       º
  26. echo º : = Exponent       º
  27. echo º $ = Factoral       º
  28. echo º E = *10^^#          º
  29. echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  30. call :echoans
  31. echo ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  32. set /a a+=1
  33. set /p UDefine=
  34. if /i "%UDefine%"=="functions" (
  35. set /a a-=1
  36. goto functions
  37. )
  38. if /i "%UDefine%"=="options" goto options
  39. if /i "%UDefine%"=="o" goto options
  40. if /i "%UDefine%"=="exponent" goto exponent
  41. if /i "%UDefine%"=="e" goto exponent
  42. if /i "%UDefine%"=="factoral" goto factoral
  43. if /i "%UDefine%"=="f" goto factoral
  44. if /i "%UDefine%"=="help" goto help
  45. if /i "%UDefine%"=="h" goto help
  46. set /a answer%a%=%UDefine%
  47. if %a%==9 call :shiftans %UDefine% top
  48. set ans%a%=%UDefine%=!answer%a%!
  49. goto top
  50.  
  51. :exponent
  52. echo You'll be prompted 2 times.
  53. echo One for the base and a second for the power.
  54. echo The minimum power is 0.
  55. echo To exit exponent mode, type "top" as the base.
  56. set /p base=Base:
  57. set /p power=Power:
  58. if %base%==top goto top
  59. if %power% LSS 0 (
  60. echo Invalid power
  61. ping -n 3 localhost > nul
  62. cls
  63. goto exponent
  64. )
  65. set answer%a%=1
  66. set c=0
  67. :loop
  68. if %c%==%power% goto next
  69. set /a answer%a%*=%base%
  70. set /a c+=1
  71. goto loop
  72. :next
  73. if %a%==9 call :shiftans %base%:%power% top
  74. set ans%a%=%base%:%power%=!answer%a%!
  75. goto top
  76.  
  77. :factoral
  78. echo Just type the number you'd like to take the factoral of.
  79. echo The number must be greater than or equal to zero (0)
  80. set /p fact=
  81. if %fact% lss 0 (
  82. cls
  83. goto factoral
  84. )
  85. set facter=%fact%
  86. set answer%a%=1
  87. :fact1
  88. if %facter%==1 goto nextfact
  89. set /a answer%a%*=%facter%
  90. set /a facter-=1
  91. goto fact1
  92. :nextfact
  93. if %a%==9 call :shiftans %fact%$ top
  94. set ans%a%=%fact%$=!answer%a%!
  95. goto top
  96.  
  97. :help
  98. setlocal disabledelayedexpansion
  99. echo Just type the equation you'd like to see done.
  100. echo You can also use "!answer#!" to use a given answer.
  101. echo The # sign represents a number of your choice from one of the lines.
  102. echo To use an exponent, type "exponent" or "e".
  103. echo To use factorals, type "factoral" or "f".
  104. echo.
  105. echo PLEASE KEEP IN MIND: Batch always rounds down. 3/2 will give you 1.
  106. echo Therefore, it may not be worthwhile to use this for division...
  107. echo To keep things simple, I didn't bother with certain functions for obvious reasons.
  108. pause
  109. setlocal enabledelayedexpansion
  110. set /a a-=1
  111. goto top
  112. :functions
  113. cls
  114. echo Welcome to the functions section.
  115. echo Here you will be able to define single variable functions.
  116. echo Keep in mind, batch always rounds down.
  117. echo Example: F(x)=x/2. If x=1, f(x)=1/2 but batch will calculate 0.
  118. echo You'll have to choose the type of function you want to input before.
  119. echo You can also type "top" to return to the top.
  120. echo For the moment, all functions must be entered in "simplified" form.
  121. echo Example: f(x)=4(x+2)(squared) +3
  122. :menuf
  123. echo.
  124. echo These are your options:
  125. echo 1) Polynomial (F(x)=(a(x-h)^^e)+k)
  126. echo 2) Absolute Value (G(x)=a^|x-h^|+k)
  127. echo 3) Rational (H(x)=(a/(x-h))+k)
  128. echo 4) Linear (I(x)=ax+b)
  129. set /p optionf=
  130. if %optionf%==1 goto polynomial
  131. if %optionf%==2 goto absolute
  132. if %optionf%==3 goto rational
  133. if %optionf%==4 goto linear
  134. if %optionf%==top goto top
  135. echo Invalid option, try again.
  136. ping -n 3 localhost > nul
  137. cls
  138. goto menuf
  139. :polynomial
  140. cls
  141. echo Polynomials in simple form are of the following:
  142. echo F(x)=r(x-h)^^e +k
  143. echo where r is the rate of change.
  144. echo where h,k is the vertex
  145. echo and where e is the power of which the function is raised.
  146. echo a should not be zero (0) and e should be greater than zero (0).
  147. set /p r=Value for r:
  148. set /p h=Value for h:
  149. set /p e=Value for e:
  150. set /p k=Value for k:
  151. :checkpoly
  152. if %r%==0 (
  153. set /p a=Please enter a new value for r:
  154. goto checkpoly
  155. )
  156. if not %e% GTR 0 (
  157. set /p e=Please enter a new value for e:
  158. goto checkpoly
  159. )
  160. :askcorrectfp
  161. echo Is this correct? F(x)=%r%(x-%h%)^^%e% +%k%
  162. set /p askfp=(Y/N)
  163. if %askfp%==n goto functions
  164. :continuefp
  165. cls
  166. echo Type "top" to go to top
  167. echo Type "f" to change functions
  168. echo.
  169. echo F(x)=%r%(x-%h%)^^%e% +%k%
  170. call :echoans
  171. set /p x=What would you like to set x as?
  172. if /i %x%==top goto top
  173. if /i %x%==f goto functions
  174. set /a a+=1
  175. set /a base=(%x%-%h%)
  176. set answer%a%=1
  177. set c=0
  178. :loopfp
  179. if %c%==%e% goto nextfp
  180. set /a answer%a%*=%base%
  181. set /a c+=1
  182. goto loopfp
  183. :nextfp
  184. set /a answer%a%=(%r%*!answer%a%!)+%k%
  185. if %a%==9 call :shiftans F(%x%) continuefp
  186. set ans%a%=F(%x%)=!answer%a%!
  187. goto continuefp
  188.  
  189.  
  190. :absolute
  191. cls
  192. echo Absolutes in simple form are of the following:
  193. echo G(x)=r^|x-h^|+k
  194. echo where r is the rate of change.
  195. echo where h,k is the vertex
  196. echo a should not be zero (0).
  197. set /p r=Value for r:
  198. set /p h=Value for h:
  199. set /p k=Value for k:
  200. :checkabso
  201. if %r%==0 (
  202. set /p r=Please enter a new value for r:
  203. goto checkabso
  204. )
  205. :askcorrectfa
  206. echo Is this correct? G(x)=%r%^|x-%h%^|+%k%
  207. set /p askfa=(Y/N)
  208. if %askfa%==n goto functions
  209. :continuefa
  210. cls
  211. echo Type "top" to go to top
  212. echo Type "f" to change functions
  213. echo.
  214. echo G(x)=%r%^|x-%h%^|+%k%
  215. call :echoans
  216. set /p x=What would you like to set x as?
  217. if /i %x%==top goto top
  218. if /i %x%==f goto functions
  219. set /a a+=1
  220. set /a base=(%x%-%h%)
  221. set answer%a%=1
  222. if %base% LSS 0 set /a base*=-1
  223. set /a answer%a%*=%base%
  224. set /a answer%a%=(%r%*!answer%a%!)+%k%
  225. if %a%==9 call :shiftans G(%x%) continuefa
  226. set ans%a%=G(%x%)=!answer%a%!
  227. goto continuefa
  228.  
  229. :rational
  230. cls
  231. echo Rationals in simple form are of the following:
  232. echo H(x)=(r/x-h)+k
  233. echo where r is the rate of change.
  234. echo where h is the horizontal asymptote.
  235. echo and k is the vertical asymptote.
  236. echo a should not be zero (0).
  237. set /p r=Value for r:
  238. set /p h=Value for h:
  239. set /p k=Value for k:
  240. :checkrati
  241. if %r%==0 (
  242. set /p r=Please enter a new value for r:
  243. goto checkrati
  244. )
  245. :askcorrectfr
  246. echo Is this correct? H(x)=(%r%/x-%h%)+%k%
  247. set /p askfr=(Y/N)
  248. if %askfr%==n goto functions
  249. :continuefr
  250. cls
  251. echo Type "top" to go to top
  252. echo Type "f" to change functions
  253. echo.
  254. echo H(x)=(%r%/%x%-%h%)+%k%
  255. call :echoans
  256. set /p x=What would you like to set x as?
  257. if /i %x%==top goto top
  258. if /i %x%==f goto functions
  259. set /a a+=1
  260. set /a base=(%x%-%h%)
  261. set answer%a%=%r%
  262. set /a answer%a%/=%base%
  263. set /a answer%a%=!answer%a%!+%k%
  264. if %a%==9 call :shiftans H(%x%) continuefr
  265. set ans%a%=H(%x%)=!answer%a%!
  266. goto continuefr
  267.  
  268.  
  269. :linear
  270. cls
  271. echo Linear in simple form are of the following:
  272. echo I(x)=rx+b
  273. echo where r is the rate of change.
  274. echo where b is the y-intercept.
  275. echo a should not be zero (0).
  276. set /p r=Value for r:
  277. set /p b=Value for b:
  278. :checkline
  279. if %r%==0 (
  280. set /p r=Please enter a new value for r:
  281. goto checkabso
  282. )
  283. :askcorrectfl
  284. echo Is this correct? I(x)=%r%x+%b%
  285. set /p askfl=(Y/N)
  286. if %askfl%==n goto functions
  287. :continuefl
  288. cls
  289. echo Type "top" to go to top
  290. echo Type "f" to change functions
  291. echo.
  292. echo I(x)=%r%x+%b%
  293. call :echoans
  294. set /p x=What would you like to set x as?
  295. if /i %x%==top goto top
  296. if /i %x%==f goto functions
  297. set /a a+=1
  298. set /a answer%a%=(%r%*%x%)+%b%
  299. if %a%==9 call :shiftans I(%x%) continuefl
  300. set ans%a%=I(%x%)=!answer%a%!
  301. goto continuefl
  302.  
  303. :options
  304. cls
  305. echo 1) Graph options
  306. set /p opt1=What options menu would you like to go to? (Enter top to go back)
  307. if /i "%opt1%"=="top" goto top
  308. if "%opt1%"=="1" goto graphopt
  309. echo Invalid input, returning to main menu.
  310. ping -n 2 localhost > nul
  311. goto top
  312. :graphopt
  313. cls
  314. echo 1) Enable/disable graphs (beta)
  315. echo 2) Change graph size
  316. echo 3) Test graph
  317. set /p graphopt1=What options menu would you like to go to? (Enter top to go back)
  318. if "%graphopt1%"=="top" goto top
  319. if "%graphopt1%"=="1" goto enablegraph
  320. if "%graphopt1%"=="2" goto graphsize
  321. if "%graphopt1%"=="3" goto testgraph
  322. echo Invalid input. Please try again.
  323. ping -n 2 localhost > nul
  324. goto graphopt
  325. :enablegraph
  326. echo Graphing for functions allows the points to be plotted on a basic graph.
  327. echo This is currently in beta and only works on functions, factoral and exponent calculations.
  328. echo (Please keep in mind that the size of the graph limits the possible points plotted)
  329. echo (Increase the size of the graph if you plan on plotting data sets with larger values)
  330. set /p graphs=Enter 1 to enable graphs or 0 to disable graphs.
  331. if "%graphs%"=="1" set graph=1
  332. goto top
  333.  
  334.  
  335. :graphsize
  336. echo Enter "top" to go back to the main menu.
  337. Enter "d" or "default" to return both values to default and go to top.
  338. set /p uz=Enter the x extension for the function graphs:
  339. if /i "%uz%"=="top" goto top
  340. if /i "%uz%"=="default" set y=10&set z=10&goto top
  341. set z=%uz%
  342. echo X extension value saved.
  343. echo.
  344. set /p uy=Enter the y extension for the function graphs:
  345. if /i "%uy%"=="top" goto top
  346. if /i "%uy%"=="default" set y=10&set z=10&goto top
  347. echo y extension value saved.
  348. ping -n 3 localhost > nul
  349. goto top
  350.  
  351. :testgraph
  352. cls
  353. echo Enter the points you wish to push to the graph in the form "x,y" (without the quotes)
  354. echo Press space and enter to stop the input of coordinates.
  355. echo.
  356. set /p p1=Enter point 1:
  357. if "%p1%"==" " call :graph "%z%,%y%"
  358. set /p p2=Enter point 2:
  359. if "%p2%"==" " call :graph "%z%,%y%" "%p1%"
  360. set /p p3=Enter point 3:
  361. if "%p1%"==" " call :graph "%z%,%y%" "%p1%" "%p2%"
  362. set /p p4=Enter point 4:
  363. if "%p1%"==" " call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%"
  364. set /p p5=Enter point 5:
  365. if "%p1%"==" " call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%" "%p4%"
  366. set /p p6=Enter point 6:
  367. if "%p1%"==" " call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%" "%p4%" "%p5%"
  368. set /p p7=Enter point 7:
  369. if "%p1%"==" " call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%" "%p4%" "%p5%" "%p6%"
  370. set /p p8=Enter point 8:
  371. if "%p1%"==" " (
  372. call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%" "%p4%" "%p5%" "%p6%" "%p7%"
  373. ) else (
  374. call :graph "%z%,%y%" "%p1%" "%p2%" "%p3%" "%p4%" "%p5%" "%p6%" "%p7%" "%p8%"
  375. pause > nul
  376.  
  377. :echoans
  378. echo 1) %ans1%
  379. echo 2) %ans2%
  380. echo 3) %ans3%
  381. echo 4) %ans4%
  382. echo 5) %ans5%
  383. echo 6) %ans6%
  384. echo 7) %ans7%
  385. echo 8) %ans8%
  386. exit /b
  387.  
  388. :shiftans
  389. set ans1=%ans2%
  390. set ans2=%ans3%
  391. set ans3=%ans4%
  392. set ans4=%ans5%
  393. set ans5=%ans6%
  394. set ans6=%ans7%
  395. set ans7=%ans8%
  396. set ans8=%1=!answer%a%!
  397. set answer1=%answer2%
  398. set answer2=%answer3%
  399. set answer3=%answer4%
  400. set answer4=%answer5%
  401. set answer5=%answer6%
  402. set answer6=%answer7%
  403. set answer7=%answer8%
  404. set a=8
  405. goto %2
  406.  
  407.  
  408.  
  409.  
  410. :graph
  411. set t1=(%~2)
  412. set t2=(%~3)
  413. set t3=(%~4)
  414. set t4=(%~5)
  415. set t5=(%~6)
  416. set t6=(%~7)
  417. set t7=(%~8)
  418. set t8=(%~9)
  419. echo %1
  420. set z=%~1
  421. echo %z%
  422. set z=%z:~0,1%
  423. set y=%~1
  424. echo %y%
  425. set y=%y:~2,1%
  426. echo %z% %y%
  427. pause
  428. set /a x2=%z%*2+1
  429. set /a x3=%x2%-%z%
  430. set /a x4=(%z%+5)*2
  431. set /a y4=(%y%+5)*2
  432. set /a y2=%y%*2+1
  433. set /a y3=%y2%-%y%
  434. ::echo values for check
  435. for /l %%a in (1,1,8) do echo !t%%a!
  436. pause
  437. ::end echo
  438. mode %x4%,%y4%
  439.  
  440. :setvars
  441. for /l %%a in (1,1,%x2%) do (
  442. for /l %%b in (%y2%,-1,1) do (
  443. set %%a,%%b=
  444. if "%%a"=="%x3%" set %%a,%%b
  445. )
  446. set (%%a,%y3%)
  447. )
  448. set (%x3%,%y3%)
  449. :prebuild
  450. set b=%y2%
  451. :builder
  452. set c=1
  453. :loop
  454. set ly%b%=!ly%b%!!(%c%,%b%)!
  455. if "%c%"=="%x2%" goto next
  456. set /a c+=1
  457. goto loop
  458. :next
  459. if %b%==1 goto nextnext&set s=1
  460. set /a b-=1
  461. goto builder
  462. :nextnext
  463. if "!t%s%!"=="" goto echograph
  464. set /a changex=%x3%+!t%s%:~0,1!
  465. set /a changey=%y3%+!t%s%:~2,1!
  466. set (%changex%,%changey%)=%s%
  467. set /a s+=1
  468. goto nextnext
  469. :echograph
  470. for /l %%d in (%y2%,-1,1) do (
  471. echo !ly%%d!
  472. )
  473. for /l %%e in (1,1,%y2%) do set ly%%e=
  474. goto testgraph
Advertisement
Add Comment
Please, Sign In to add comment