This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's
Your Projects subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.
Project Ideas/Start New Projects =>
Your Projects
Author |
Message |
|
Deep Thought
Advanced Newbie
Joined: 09 Jun 2009 Posts: 59
|
Posted: 15 Apr 2010 07:07:48 pm Post subject: |
|
|
[size="2"]I'm pretty sure this hasn't really been done before, at least in TI-BASIC, but if something similar exists, please notify me.
Last year, I was absolutely amazed by the simplicity and ingenuity of Google Calculator, especially where you can type in any expression using any units (and an optional unit to convert to), and I decided that that was something someone needed to code for TI calculators. Thus I went on a coding rage, and actually got much of it done within a month, to the point where you could type in something like 7 M * IN INTO CM CM and it would display 1778. Unfortunately, I couldn't figure out division, parentheses, or exponents, so I set it aside and continued with other projects. One day, I really needed to clear some ARC space, so I deleted the group where I had saved it (I called it CALCALCA). I finally started regretting this decision, and will start coding it again, but I really need help with the issues I mentioned above.
This is what I've decided for the program so far:
1. It will use a blank input (Input "",Str1) to input a continuous expression.
2. The resultant string will searched through first for illegal characters.
3. The string is checked a second time, this time for the characters INTO (which specifies that the following units say what unit the user wants)
4. First, ( is added to the beginning, and ) to the end, just for padding (i.e., "("+Str1+")"->Str1
5. The string is then evaluated, one character at a time.
a. Whenever it hits a space, it tests to see whether * follows it.
i. If there is one, the space is deleted by using sub('s for the two sides of the string.
ii. If there is not, the space is replaced with )(, which assumes the space meant implied multiplication.
b. Whenever it hits a letter, a subloop gets the entire combination of letters, which is saved to another string for checking.
i. The second string is checked against a database of all the units to be supported (see note below).
ii. If there is a match, that entire section of the main string is replaced with the numerical value of the unit, and a the unit's base units are added to a list (see second note below).
6. When this is all done, the program will evaluate the string (with an exp() and (theoretically) appends the final unit.
Note:
The database consists of a huge (literally, huge, and might even be larger than the program itself) string containing each supported unit in the format:
Code:
" 2 Pa -1 01 00 -2 1.00000000 ..."
^ ^ | | ^ ^
| | +------------------+ | |
| | | | |
Length of Unit name. These four numbers are the How many of the Continue
unit name. base units for the unit, in unit fit into onto next
the order {length, mass, the base unit. unit.
current, time}. For example, Since pascals are
Pa=N/(m^2) the base for
=(kg*m/(s^2))/(m^2) pressure, this
=kg/(s^2)/m would be a one
so is mass (the positive (the zeroes are
one) divided by time squared because it needs
(the negative two) divided by to have exactly
length (the negative one). ten characters).
Can anyone help me with this program?[/size]
[size="2"]By the way, if anyone can't read the above code, I attached it as a .txt:[/size]
[size="2"][attachment=3162:BLAH.txt]
[/size]
Last edited by Guest on 28 May 2010 05:36:43 pm; edited 1 time in total |
|
Back to top |
|
|
Galandros
Active Member
Joined: 29 Aug 2008 Posts: 565
|
|
Back to top |
|
|
Deep Thought
Advanced Newbie
Joined: 09 Jun 2009 Posts: 59
|
Posted: 25 May 2010 11:01:29 am Post subject: |
|
|
What about a BASIC version? Before I deleted it, the program CALCALCA took up (I think) just under 5 KB, with the bulk of the memory used for the unit string. It would also, if the programming goes well, be extremely easy to use — just type an expression into a blank input, with no quotes, formatting, or >Frac required.
Also, I'm pretty new to this forum, and I can't find the topic I'm posting in right now (I got to it by using my posting history). Where is this post located?
EDIT: And now it's back. Is it automatically being hidden?
Last edited by Guest on 04 Jun 2010 10:39:41 am; edited 1 time in total |
|
Back to top |
|
|
Deep Thought
Advanced Newbie
Joined: 09 Jun 2009 Posts: 59
|
Posted: 04 Jun 2010 10:38:55 am Post subject: |
|
|
Sorry for the double-post, but I've moved updates to Omnimaga: [font="arial, sans-serif"][size="2"]http://www.omnimaga.....php?topic=3351.[/size]
Last edited by Guest on 04 Jun 2010 10:39:12 am; edited 1 time in total |
|
Back to top |
|
|
|
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