litestep : modules : googlecalc.dll

Goglecalc is Litestep module that utilizes and integrates one of google's most interesting features: google calculator into Litestep core.

According to google‘s help:

“To use Google‘s built-in calculator function, simply enter the calculation you‘d like done into
the search box and hit the Enter key or click on the Google Search button. The calculator can solve
math problems involving basic arithmetic, more complicated math, units of measure and conversions,
and physical constants.”

Real fun is, that google calculator is able to solve not just plain arithmetics but as well
some advanced stuff like:

It can convert between measurement units and even currency conversions are working:

You can read more on google calculator in google documentation.

Googlecalc plugin provides !GoogleCalc bang command. Using this command will transparently
query google search and if the returned result is valid calculator result (not every query is valid
for calculation), it will run specified command. You can run any program, display message box or even
return the result into LSXCommand prompt (see below).

Example

Using following simple step.rc settings you can extend LSXCommand computing functionality to include
google-calculator features:

# This setup assumes that LSXCommand is loaded and correctly set up.
# Load googlecalc module
LoadModule c:\litestep\googlecalc-1.1.dll

# Define proxy.
# Not mandatory, if not set, Windows defaults are used.
# If set to "none", direct connection is always used.
GoogleProxy none

# Define what to do with the result
GoogleCalcOnResult !CommandSetText %s

# Define LSXCommand special character for googlecalc
*commandChar # !googlecalc <args>

You will be able to do a google-calculator query right within your LSXCommand prompt starting your query with # like:

#half a cup in teaspoons

and result is returned into LSXCommand prompt as:

half (1 US cup) = 24 US teaspoons

Settings

Bang commands:

Invoke google calculator search with given arguments

!GoogleCalc <args>

Settings:

Show verbose messages (set on for debugging purposes only).

GoogleVerbose

Define proxy. This setting is not mandatory, if not set, Windows defaults are used.
If set to “none“, direct connection is always used.

GoogleProxy <proxy_host:proxy_port>

Specify what to do with the result. Specify path to executable or bang command, put %s in place where
the result should be expanded. See example above:

GoogleCalcOnResult <args>

Notes

googlecalc.dll module utilizes internal Windows Internet API (wininet.dll) to send http GET request to google in the form www.google.com/search?q=<yourquery>%3D and then seek in returned HTML
response for signs that the result is calculator-result and parse the resulting value.
It reads only essential part of the server response and closes the connection as soon as the result
is gathered.

Downloads

Current version is 1.1

Module download: googlecalc-1.1.zip
Source download: googlecalc-1.1-src.zip
changelog
documentation (txt wiki file)
Sample step.rc config

Bugtracker

currently open bugs (max 20):

    currently open feature requests (max 20):

      Report bug/request feature login: reporter / nospammer

      issuetracker

      Development

      Upcoming version 1.2 changelog:

      none yet

      CVS repository

      Another resources

      Notes

      ubergeek: below are the additions I had to make to get this to compile under Dev-C++ 4.9.9.2 (gcc 3.4.2, that is):

      1. add my [litestep]/source/lsapi and [litestep]/source/utility as include paths (for lsapi.h and wharfdata.h respectively)
      2. main.h: need type for “extern proxy_port“. I searched and couldn‘t find this used anywhere in the other source files, so I just changed it to “extern int proxy_port” and it seems to work (not that I use a proxy).
      3. googlecalc.cpp: need to put #include <string> BEFORE #include “main.h“, and also “using namespace std;” somewhere. If string doesn‘t go before main.h, it doesn‘t get included before windows.h, and then there are compile errors within basic_string, and…yuck
      4. #define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 //it‘s not defined in my wininet.h for some reason
      5. link project with lsapi.dll and libwininet.a

      hope this helps someone (yes I tested and not only does it compile, it works)
      p.s. WIN32_LEAN_AND_MEAN isn‘t going to do anything if you don‘t include it before windows.h

      Discussion

      XADNA
       
      projects/modules/googlecalc.txt · Last modified: 2007/02/09 17:14 UTC by 127.0.0.1
       
      Recent changes RSS feed Creative Commons License Donate to DokuWiki author Valid XHTML 1.0 Valid CSS Driven by DokuWiki Debian served Run on Apache Powered by PHP eAccelerated