I need a cool looking, omnipotent, decimal-supporting batch calculator

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

I need a cool looking, omnipotent, decimal-supporting batch calculator

Post by MigrationUser »

28 Jan 2014 14:47
Evanator

I once tried making a sort of thing with decimals, but it was really clumsy and didn't work all the time.
So here's what I ask of some of you, like you, Aacini:

-A powerful calculator that...
-Doesn't use 'set /a', rather an external program(s)
-Supports float values, exponents, sines, cosines, and more
-Can draw a graph of two or more lines from an equation that
can be in slope-intercept format or not
-Can do just that, and be able to have the user use the mouse
for graphing
-Can show how some problems were done, like this:

24
X 15
-----
120
+ 24
-----
144

I hope you see this, because I can't really do a terribly large amount of things with the knowledge I have, and I can adapt and learn from code you write to help add to my knowledge of batch too. Oh, and I might need something like this for math class. I looked up some things and it wasn't helpful.

----------------------------

#2 28 Jan 2014 18:29
npocmaka

Here you can find 'hand`n`paper' emulation of addition :http://www.robvanderwoude.com/files/add_nt.txt ; http://www.robvanderwoude.com/battech_math.php
But if I needed to do such thing I would use embedded jscript/vbscript....

----------------------------

#3 29 Jan 2014 03:30
Aacini

Wow! Don't you want that your omnipotent program turn on the coffee maker when the coffee is cold? lol

Although your request is very ambitious, I think that most of it could be done.

Arithmetic expressions and mathematic functions can be performed via JScript code, like in this example.

You can draw equations in a simple way; see the DRAWEQUATION.BAT example below 6-CursorPos.exe.hex program at this post. However, you may also draw really good graphics using the method described here.

An additional auxiliary program for mouse control may be developed; I just need to complete the design.

This way, almost any application may be written in Batch. Of course, this still require a hugh amount of work to assemble all parts together...

----------------------------

#4 29 Jan 2014 19:18
Evanator

A calculator that made servo motors turn on a coffee maker via a thermostat strapped to the coffee pot might be a nice idea, but I totally forgot that JScript could be implemented into windows batch files. Not only can JScript do floating point variables, but it can do exponents and sines and other things that the windows command prompt just points the finger to.

So in truth, I don't know how to use JScript, and I'm not a fast learner when it comes to something like that.
But you know it, and if you can make something to be able to switch from batch to JScript AND BACK TO BATCH, then the windows batch could be just used as an interface to the cold javascript below...the text file.

And as for the 'show work' thing, that really does seem a little ambitious. The line that gets graphed, however, could be handled entirely by JScript, and just simply get the slope, because all Batch does is an integer, which is annoying.

So to handle this graphing calculator a lot better, and other things too, some auxiliary programs might be needed:

-A program to draw a character of a hexadecimal color to some X and Y coordinates
-A program to get X and Y coordinates of a mouse click, and determine which mouse button it was (left, middle, right), and maybe mix this with GetKey
-A program to end all programs (just kidding)

And maybe with an arduino, there could be a robot to turn on a coffee pot when a thermostat reaches a low enough temperature.

----------------------------

#5 29 Jan 2014 21:16
npocmaka
Evanator wrote:

So in truth, I don't know how to use JScript, and I'm not a fast learner when it comes to something like that.
But you know it, and if you can make something to be able to switch from batch to JScript AND BACK TO BATCH, then the windows batch could be just used as an interface to the cold javascript below...the text file.

That's easy - check this - https://groups.google.com/d/msg/alt.msd ... oVLRo1uOsJ

I think this is the first post that uses jscript directives (@if ... ) for hybridization between jscript/batch without temp file. You call the jscript part from the batch how many times you want.
It's possible to create a vbscript/batch hybrid but it never can be so perfect .Despite vbscript has some features missing in jscript I'll strongly recommend the jscript/javascript.

----------------------------

#6 15 Feb 2014 10:14
Aacini

The first version of the decimal Batch calculator you requested is here:

Image

I am working now in the equation definition and drawing parts. I left the temperature sensor and servo motors control modules for the last part! wink

Antonio

Last edited by Aacini (12 Apr 2014 16:57)

----------------------------

#7 04 Mar 2014 00:37
Evanator

Hey Antonio, I couldn't seem to find the 'ColorChar' or 'GetInput' auxiliary programs. Could you go host a download of both of them on something like Dropbox, and give us the links?

----------------------------

#8 04 Mar 2014 02:09
Aacini


At that post, the last code listing is preceded by this paragraph:
Aacini wrote:

APA-Calc.bat uses several auxiliary programs, so I opted for extract the creation of all .exe files in a separated "resources" file in order to not have a huge file that would run slower.
The listing of "APA-Calc Resources.bat" file follows, and this phrase at end: You need to download previous "APA-Calc Resources.bat" file and run it just once before run APA-Calc.bat. Note that the last version of GetInput.exe auxiliary program is included there.

Antonio

----------------------------

#9 15 Mar 2014 14:51
Evanator

It has all the files, but GetInput isn't taking mouse input when called at cmd.

----------------------------

#10 16 Mar 2014 12:27
Aacini

Excuse me. I am afraid I am somewhat confused...

At first, you said that "I couldn't seem to find the 'ColorChar' or 'GetInput' auxiliary programs", but now you said "GetInput isn't taking mouse input". I need more data in order to try to find a possible bug! How did you tested GetInput? What happened? Please, open a command-line window, cd to the subdir where GetInput.exe file is, run GetInput, press a mouse button at any place inside the command-line window and then enter ECHO %ERRORLEVEL%. A negative number should appear; if not, please report what number appear and your Windows version.

Or, better yet, copy the example code from GetInput help screen (listed at beginning of the link above) and test it at several mouse positions. Here it is:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

   GetInput
   if %errorlevel% gtr 0 (
      echo Key pressed: %errorlevel%
   ) else (
      rem Mouse button clicked
      set /A "input=-%errorlevel%, row=input >> 16, col=input & 0xFFFF"
      if !col! lss 32768 (
         echo LEFT button click at !row!,!col!
      ) else (
         set /A col-=32768
         echo RIGHT button click at !row!,!col!
      )
   )
APA-Calc.bat program requires ColorChar.exe, CursorPos.exe, and GetInput.exe auxiliary files. Please, execute APA-Calc program from the command-line window and report what happened. Error messages are shown? Calculator skin appear but not respond to the input? Just respond to keyboard input, but not to mouse clicks? Any other? The program requires a CD "%~P0" command placed below the SETLOCAL in order to be executed via a double-click from the explorer...

Antonio

----------------------------

#11 16 Mar 2014 18:22
Evanator

I'll try to be clear with my problems:

-I open CMD and call GetInput with 'C:\Users\Evanator\Desktop>getinput':
It waits for input, but it won't react at all with any input from the mouse. The keyboard, however, works fine.
-I click on and open GetInput from the desktop:
It opens a blank window of CMD and will take both mouse and keyboard input

So, when I opened your batch file, I had clicked in the window, but nothing happened.

I am running Windows Vista SP2 32 bit. Try to find the bug, please.

----------------------------

#12 16 Mar 2014 21:12
Aacini

So, GetInput program fail when it is executed from the command line, but works if it is executed via a double-click in the desktop? If so, then the calculator should correctly work if it is executed via a double-click! Please, insert a CD "%~P0" command below the SETLOCAL line in APA-Calc.bat and execute it with a double-click in the desktop.

This is strange. It seems that a mouse related parameter is set to a certain value when cmd.exe is executed by itself, but is set to a different value if cmd.exe is executed as request from another program or Batch file! Perhaps other Windows Vista users have the same problem? GetInput.exe program set ENABLE_MOUSE_INPUT and clear ENABLE_QUICK_EDIT_MODE that are the only two console parameters related to mouse input accordingly to SetConsoleMode Win32 API function documentation, so I really don't know what additional tests may I do to fix this problem. Perhaps someone else may give us any additional advice (carlos?).

The second module (the Algebraic calculator with calculations history) is almost ready, but I can't post more code until this problem have been fixed.

Antonio
Post Reply