{"id":37343,"date":"2018-04-13T03:01:30","date_gmt":"2018-04-12T17:01:30","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=37343"},"modified":"2022-03-14T18:35:48","modified_gmt":"2022-03-14T08:35:48","slug":"tcl-and-php-calculator-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/tcl-and-php-calculator-tutorial\/","title":{"rendered":"Tcl and PHP Calculator Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/calculator.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Tcl and PHP Calculator Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/calculator.jpg\" title=\"Tcl and PHP Calculator Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Tcl and PHP Calculator Tutorial<\/p><\/div>\n<p>The <a title='Tcl and PHP Primer Tutorial' href='#tphppt'>Tcl and PHP Primer Tutorial<\/a> was a foretaste to today&#8217;s calculator web application that &#8230;<\/p>\n<ul>\n<li>uses PHP as a frontend and (HTML) form navigation destination &#8230;<\/li>\n<li>connects to backend via PHP <a target=_blank title='PHP exec() method information' href='http:\/\/php.net\/manual\/en\/function.exec.php'>exec<\/a> &#8230;<\/li>\n<li>uses TCL as backend &#8230; via &#8230;<br \/>\n<code><br \/>\nexec(\"tclsh <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/calculator.tcl_GETME' title='calculator.tcl'>calculator.tcl<\/a> &lt; calculator.txt | tail -1 &gt; calculator.out\");<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p>Crucial to the TCL&#8217;s backend role is TCL&#8217;s <a target=_blank title='Tcl expr command information' href='https:\/\/www.tcl.tk\/man\/tcl\/TclCmd\/expr.htm'>expr<\/a> command, as a determinant regarding what today&#8217;s calculator is capable of.<\/p>\n<p>Here is a link to some downloadable PHP source code <a target=_blank title='calculator.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/calculator.php_GETME\">calculator.php<\/a> supervising <a target=_blank title='calculator.tcl' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/calculator.tcl_GETME\">calculator.tcl<\/a> TCL source code, and here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/calculator.php\" title=\"Click picture\">live run<\/a> link.<\/p>\n<hr>\n<p id='tphppt'>Previous relevant <a target=_blank title='Tcl and PHP Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tcl-and-php-primer-tutorial'>Tcl and PHP Primer Tutorial &#8230; http:\/\/www.tcl.tk\/software\/tcltk\/<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/domain.php\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Tcl and PHP Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/domain.jpg\" title=\"Tcl and PHP Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Tcl and PHP Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/<\/p><\/div>\n<p>Have you heard of <a target=_blank title='Tcl\/Tk landing page' href='http:\/\/www.tcl.tk\/software\/tcltk\/'>Tcl\/Tk?<\/a>   Think maybe you could introduce yourself to it with <a target=_blank href='#tsbpt' title='Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial'>Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial<\/a> as shown below.<\/p>\n<p>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 <a target=_blank title='PHP exec information' href='http:\/\/php.net\/manual\/en\/function.exec.php'><i>exec<\/i><\/a> method to ask something of Tcl and get something back, half of which is the arrangement we&#8217;d like to have when feeding our babies.<\/p>\n<p>Today we write a webpage for finding the Country of Origin of a designated URL where PHP supervises Tcl:<\/p>\n<ol>\n<li>ask for a URL in PHP,<\/li>\n<li>send that to the same PHP with a different call &#8230;<\/li>\n<li>and use PHP exec method to send a Tcl commend line command to Tclsh and output this to a file known by the PHP,<\/li>\n<li>get the PHP to read the file of step 3. and send that information in a modified call of this same PHP,<\/li>\n<li>write out the Tcl based findings to the webpage in PHP,<\/li>\n<li>ask for a URL in PHP<\/li>\n<\/ol>\n<p>Here is a link to some downloadable PHP source code <a target=_blank title='domain.php' href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/domain.php_GETME\">domain.php<\/a> supervising <a target=_blank title='domain.tcl' href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/domain.tcl_GETME\">domain.tcl<\/a> TCL source code, and here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/domain.php\" title=\"Click picture\">live run<\/a> link.<\/p>\n<p>Thanks to:<\/p>\n<ul>\n<li><a target=_blank title='link' href='http:\/\/zetcode.com\/lang\/tcl\/flowcontrol\/'>Flow control in Tcl<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/dbaspot.com\/shell\/362549-tcsh-argv-loses-quotes-messes-argument-grouping-up.html'>[tcsh] $argv loses quotes, messes argument grouping up<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/bin-co.com\/tcl\/articles\/variables_in_arrays.php'>Using Variables in Associative Arrays<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/docstore.mik.ua\/orelly\/unix3\/upt\/ch37_05.htm'>Quoting and Command-Line Parameters<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/books.google.com.au\/books?id=BJpkh3RdG_UC&#038;pg=PA45&#038;lpg=PA45&#038;dq=%22tclsh+split%22&#038;source=bl&#038;ots=PpQlwTydXv&#038;sig=NIqU0g5LTutl9QEmakxbRCxVhpw&#038;hl=en&#038;sa=X&#038;ei=OSk_VJXRLMLCmQWms4DACA&#038;ved=0CB8Q6AEwAA'>Exploring Expect: A Tcl-based Toolkit for Automating Interactive Programs<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/tmml.sourceforge.net\/doc\/tcl\/split.html'>Split a string into a proper Tcl list<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/en.wikipedia.org\/wiki\/Country_code_top-level_domain'>Country code top-level domain<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/www.thrall.org\/domains.htm'>Top Level Domain Names and Country Codes<\/a><\/li>\n<li><a target=_blank title='link' href='http:\/\/www.tutorialspoint.com\/tcl-tk\/pdf\/tcl_strings.pdf'>Tcl &#8211; Strings<\/a><\/li>\n<\/ul>\n<hr \/>\n<p id='tsbpt'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=664' title='Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial'>Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/TCL_Example_1of.png\" title=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\"  style=\"float:left;\" \/><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\" src=\"http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/TCL_Example_4of.png\" title=\"Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Tcl\/Tk So Brilliant (but where do you start?) Primer Tutorial ... http:\/\/www.tcl.tk\/software\/tcltk\/<\/p><\/div>\n<p>Have you heard of Tcl\/Tk?<\/p>\n<blockquote><p>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.<\/p><\/blockquote>\n<p>With Tcl\/Tk have used in conjunction with C++ and Python (look out for Tkinter).<\/p>\n<p>Use it for Games Programming (it makes pretty cute GUIs &#8230; 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 &#8230; any advice anywhere?) and had it going on Windows XP with Visual Studio Express as well.   It has a lot of cross-platform strengths.<\/p>\n<p>Think Tcl\/Tk is really really good.<\/p>\n<p>In this primer  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/TCL\/MacExample\/'>tutorial<\/a> 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.<\/p>\n<p>Link to Tcl\/Tk website &#8230; <a target=_blank href='http:\/\/www.tcl.tk\/software\/tcltk\/' title='Home of Tcl\/Tk'>Home of Tcl\/Tk &#8230; where quote up the top resides<\/a><br \/>\nLink to Tcl\/Tk jobs done &#8230; <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/TCL\/' title='Examples of use of Tcl\/Tk'>Tcl\/Tk jobs done<\/a> &#8230; personal experience\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d664' onclick='var dv=document.getElementById(\"d664\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?cat=51\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d664' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d10261' onclick='var dv=document.getElementById(\"d10261\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=Tcl\/Tk\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10261 style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37343' onclick='var dv=document.getElementById(\"d37343\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/exec\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37343' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Tcl and PHP Primer Tutorial was a foretaste to today&#8217;s calculator web application that &#8230; uses PHP as a frontend and (HTML) form navigation destination &#8230; connects to backend via PHP exec &#8230; uses TCL as backend &#8230; via &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/tcl-and-php-calculator-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[125,2251,405,2524,468,2269,932,997,1105,1245,1247,1319],"class_list":["post-37343","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-backend","tag-calculator","tag-exec","tag-expr","tag-frontend","tag-operator","tag-php","tag-programming","tag-script","tag-tcl","tag-tclsh","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/37343"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=37343"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/37343\/revisions"}],"predecessor-version":[{"id":55158,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/37343\/revisions\/55158"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=37343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=37343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=37343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}