Itโs a โblown mindโ that has led me to involve Javascript to make the incarnation of our calculator of Tcl and PHP Calculator Tutorial allow for some round bracket functionality around the TCL (expr) โkernelโ (sorry, Unix โฆ my apologies LinusLinux). The nexus between what a user may enter, versus the hierarchy needs of TCLโs expr command just blew my mind, manperson!
So what did we turn to? Modernizing oneโs thinking? Weโre onto it? But we digress. Well, well.
We turned to Javascriptโs eval function, not PHPโs eval, nor TCLโs eval version, thanks, but no thanks. Nevertheless โฆ and didnโt you just know that โbutโ would be insulted by the paragraph above?! โฆ use of Javascript eval (for round bracketing scenarios or operator hierarchy scenarios) is not the โcakewalkโ that you may imagine. That is because โฆ
6 ** 2 // in TCL "to the power of" operator syntax (which remains our web application display choice for the user) has ...
Math.pow(6, 2) // Javascript equivalent (behind the scenes)
โฆ so we need to cater for that possibility. The Javascript logic is called at the document.body onload event.
As we often do here, the โprogressionโ of logic was to convert some โhardcodedโ HTML text (specifically โFirst Number:โ and โ:Second Numberโ) into HTML select (dropdown) elements to the left and to the right (respectively) of the โTCL kernelโ, with additional options for the round bracketing the user may want. These dropdowns move out to the edges of the webpage as they make room for user entered additions to the calculation complexity of what they want to calculate. The โMath.pow()โ logic needed benefits from the event timing thoughts on the dropdownโs onchange event logic, otherwise youโd be doing that dreaded of all dreadeds, in many programmersโ worlds methinks, tracking back through entered โcalculator equationโ texts to discover when a numerical value becomes an operator, a horrible job when a minus sign can be either, for example. These same โhorribleโ programming tasks would have been at the fore to making a โTCL only backend solutionโ come to pass, we are sure, too.
Can you see from all this how well (clientside) Javascript works with (serverside) PHP? They are a very potent duo, because it is like two bites at the cherry, every time, with their different timings of the application of their logics.
The downloadable PHP source code calculatorphp changed thisway to achieve this extension of functionality still supervising an unchanged calculator
tcl TCL source code script, and here is a live
run link for you to try this calculator for yourself.
Previous relevant Tcl and PHP Calculator Tutorial is shown below.
The Tcl and PHP Primer Tutorial was a foretaste to todayโs calculator web application that โฆ
- uses PHP as a frontend and (HTML) form navigation destination โฆ
- connects to backend via PHP exec โฆ
- uses TCL as backend โฆ via โฆ
exec("tclsh calculatortcl < calculator.txt | tail -1 > calculator.out");
Crucial to the TCLโs backend role is TCLโs expr command, as a determinant regarding what todayโs calculator is capable of.
Here is a link to some downloadable PHP source code calculatorphp supervising calculator
tcl TCL source code, and here is a live
run link.
Previous relevant Tcl and PHP Primer Tutorial โฆ //www.tcl.tk/software/tcltk/ is shown below.
Have you heard of Tcl/Tk? Think maybe you could introduce yourself to it with Tcl/Tk So Brilliant (but where do you start?) Primer Tutorial as shown below.
The Tcl in Tcl/Tk refers to the scripting side of things, while the Tk is a GUI framework. On some (maybe lots) of Linux or unix web servers, such as the one for this domain here at www.rjmprogramming.com.au Tcl scripting is available and that means Tcl could be used by PHP, as a server side language to use the exec method to ask something of Tcl and get something back, half of which is the arrangement weโd like to have when feeding our babies.
Today we write a webpage for finding the Country of Origin of a designated URL where PHP supervises Tcl:
- ask for a URL in PHP,
- send that to the same PHP with a different call โฆ
- and use PHP exec method to send a Tcl commend line command to Tclsh and output this to a file known by the PHP,
- get the PHP to read the file of step 3. and send that information in a modified call of this same PHP,
- write out the Tcl based findings to the webpage in PHP,
- ask for a URL in PHP
Here is a link to some downloadable PHP source code domainphp supervising domain
tcl TCL source code, and here is a live
run link.
Thanks to:
- Flow control in Tcl
- [tcsh] $argv loses quotes, messes argument grouping up
- Using Variables in Associative Arrays
- Quoting and Command-Line Parameters
- Exploring Expect: A Tcl-based Toolkit for Automating Interactive Programs
- Split a string into a proper Tcl list
- Country code top-level domain
- Top Level Domain Names and Country Codes
- Tcl โ Strings
Previous relevant Tcl/Tk So Brilliant (but where do you start?) Primer Tutorial is shown below.
Have you heard of Tcl/Tk?
Tcl/Tk is open source (based on a BSD-style license), so you can use it and modify it virtually any way you want, including for commercial uses.
With Tcl/Tk have used in conjunction with C++ and Python (look out for Tkinter).
Use it for Games Programming (it makes pretty cute GUIs โฆ you may disagree?!) and it used to work back at Mac OS X 10.5.8/XCode 3.0 (am going to try Mac OS X 10.7.5 โฆ any advice anywhere?) and had it going on Windows XP with Visual Studio Express as well. It has a lot of cross-platform strengths.
Think Tcl/Tk is really really good.
In this primer tutorial you can see a Draw Poker game as an XCode project, see it Build and in action, then see how to arrange for *.dmg Package Distribution via Package Manager.
Link to Tcl/Tk website โฆ Home of Tcl/Tk โฆ where quote up the top resides
Link to Tcl/Tk jobs done โฆ Tcl/Tk jobs done โฆ personal experience
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.