{"id":2765,"date":"2022-04-17T09:31:56","date_gmt":"2022-04-17T04:01:56","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=2765"},"modified":"2022-04-17T09:37:51","modified_gmt":"2022-04-17T04:07:51","slug":"calling-lisp-functions-from-xojo","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/","title":{"rendered":"Calling Lisp Functions from Xojo"},"content":{"rendered":"<p>A few days ago, I purchased <em><strong>Xojo Pro<\/strong><\/em> commercial license. In case you haven&#8217;t heard about the product, <a href=\"https:\/\/www.xojo.com\" target=\"_blank\" rel=\"noopener\"><em><strong>Xojo<\/strong><\/em><\/a>\u00a0is a popular cross-platform development tool targeting <em><strong>Desktop<\/strong><\/em>, <em><strong>Web<\/strong><\/em> and <em><strong>iOS<\/strong><\/em> (<em><strong>Android<\/strong><\/em> is expected in the near future). It supports an <em><strong>Object-Oriented Basic<\/strong><\/em> language. It has been around for over 25 years and has been steadily gaining wider adoption among developer community.<\/p>\n<p>I am a long-term user of <a href=\"https:\/\/www.embarcadero.com\/products\/rad-studio\" target=\"_blank\" rel=\"noopener\"><em><strong>RAD Studio<\/strong><\/em><\/a>\u00a0from <em><strong>Embarcadero<\/strong><\/em>, but I am always on the lookout for alternative tools, and <em><strong>Xojo<\/strong><\/em> satisfied my requirements. In fact, I have been playing with it for the past few days and I am quite pleased with what it offers.<\/p>\n<p>One of the things that caught my attention was the ease with which functions defined in external libraries, for example <em><strong>DLLs<\/strong><\/em> in <em><strong>Windows<\/strong><\/em>, could be easily called from the <em><strong>Xojo Basic<\/strong><\/em> language. This is a fundamental requirement for any extensible platform. I wanted to test this feature by calling a couple of <em><strong>Lisp<\/strong><\/em> functions defined in a <em><strong>DLL<\/strong><\/em>. The rest of this article covers the details.<\/p>\n<p>Here is the <em><strong>Lisp<\/strong><\/em> code that has been converted into a <em><strong>DLL<\/strong><\/em>:<\/p>\n<figure id=\"attachment_2767\" aria-describedby=\"caption-attachment-2767\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"2767\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/lispcode\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg\" data-orig-size=\"1072,599\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650136443&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"The Lisp Code\" data-image-description=\"&lt;p&gt;The Lisp Code&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;The Lisp Code&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode-1024x572.jpg\" class=\"wp-image-2767\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?resize=600%2C335&#038;ssl=1\" alt=\"The Lisp Code\" width=\"600\" height=\"335\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?resize=300%2C168&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?resize=1024%2C572&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?resize=768%2C429&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?resize=352%2C198&amp;ssl=1 352w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/LispCode.jpg?w=1072&amp;ssl=1 1072w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2767\" class=\"wp-caption-text\"><strong>The Lisp Code<\/strong><\/figcaption><\/figure>\n<p>The functions <em><strong>&#8220;randomInt&#8221;<\/strong><\/em> and <em><strong>&#8220;fibonacci&#8221;<\/strong><\/em> are exported from the <em><strong>DLL<\/strong><\/em>. Both the functions take an <em><strong>&#8220;Int64&#8221;<\/strong><\/em> argument and return an <em><strong>&#8220;Int64&#8221;<\/strong><\/em> value. I used <a href=\"http:\/\/www.lispworks.com\" target=\"_blank\" rel=\"noopener\"><em><strong>Lispworks Enterprise Edition 8.0<\/strong><\/em><\/a> (64 bit version for <em><strong>Windows<\/strong><\/em> 10) to build the <em><strong>DLL<\/strong><\/em>. The <em><strong>Lisp<\/strong><\/em> script to generate the <em><strong>DLL<\/strong><\/em> is shown below:<\/p>\n<figure id=\"attachment_2768\" aria-describedby=\"caption-attachment-2768\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2768\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/generatedll\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg\" data-orig-size=\"1278,565\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650136784&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Generating the DLL\" data-image-description=\"&lt;p&gt;Generating the DLL&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Generating the DLL&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL-1024x453.jpg\" class=\"wp-image-2768\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?resize=650%2C287&#038;ssl=1\" alt=\"Generating the DLL\" width=\"650\" height=\"287\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?resize=300%2C133&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?resize=1024%2C453&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?resize=768%2C340&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?resize=680%2C300&amp;ssl=1 680w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GenerateDLL.jpg?w=1278&amp;ssl=1 1278w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-2768\" class=\"wp-caption-text\"><strong>Generating the DLL<\/strong><\/figcaption><\/figure>\n<p>Now, moving on to <em><strong>Xojo<\/strong><\/em>, I created a simple <em><strong>Desktop<\/strong><\/em> App (<em><strong>Windows<\/strong><\/em>, 64 bit). Here is the design view:<\/p>\n<figure id=\"attachment_2769\" aria-describedby=\"caption-attachment-2769\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2769\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/theappdesign\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg\" data-orig-size=\"498,390\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097744&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Xojo App Design View\" data-image-description=\"&lt;p&gt;Xojo App Design View&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Xojo App Design View&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg\" class=\"size-medium wp-image-2769\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg?resize=300%2C235&#038;ssl=1\" alt=\"Xojo App Design View\" width=\"300\" height=\"235\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg?resize=300%2C235&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheAppDesign.jpg?w=498&amp;ssl=1 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2769\" class=\"wp-caption-text\"><strong>Xojo App Design View<\/strong><\/figcaption><\/figure>\n<p>Nothing fancy here. There are two edit fields to enter integers. When the <em><strong>&#8220;Randomize&#8221;<\/strong><\/em> button is pressed, the <em><strong>&#8220;randomInt&#8221;<\/strong> <strong>Lisp<\/strong><\/em> function wil be called and the result will be displayed in the text field below. Likewise, when th <em><strong>&#8220;Fibonacci&#8221;<\/strong><\/em> button is pressed, the corresponding <em><strong>Lisp<\/strong><\/em> function <em><strong>&#8220;fibonacci&#8221;<\/strong><\/em> will be called and the result shown.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>The overall <em><strong>Project<\/strong><\/em> structure is as shown below:<\/p>\n<figure id=\"attachment_2771\" aria-describedby=\"caption-attachment-2771\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2771\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/theproject\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg\" data-orig-size=\"371,645\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097675&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Project View\" data-image-description=\"&lt;p&gt;Project View&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Project View&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg\" class=\"wp-image-2771\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg?resize=300%2C522&#038;ssl=1\" alt=\"Project View\" width=\"300\" height=\"522\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg?resize=173%2C300&amp;ssl=1 173w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/TheProject.jpg?w=371&amp;ssl=1 371w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2771\" class=\"wp-caption-text\"><strong>Project View<\/strong><\/figcaption><\/figure>\n<p>Let us now look at the actual code corresponding to the <em><strong>Button<\/strong> <strong>&#8220;Pressed&#8221;<\/strong><\/em> handlers. The first one is for the <em><strong>&#8220;Randomize&#8221;<\/strong><\/em> button:<\/p>\n<figure id=\"attachment_2772\" aria-describedby=\"caption-attachment-2772\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2772\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/randomintcode\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg\" data-orig-size=\"778,272\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097596&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Randomize Button Handler\" data-image-description=\"&lt;p&gt;Randomize Button Handler&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Randomize Button Handler&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg\" class=\"wp-image-2772\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg?resize=550%2C192&#038;ssl=1\" alt=\"Randomize Button Handler\" width=\"550\" height=\"192\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg?resize=300%2C105&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg?resize=768%2C269&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/RandomIntCode.jpg?w=778&amp;ssl=1 778w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-2772\" class=\"wp-caption-text\"><strong>Randomize Button Handler<\/strong><\/figcaption><\/figure>\n<p>Since our<em><strong> Lisp DLL<\/strong><\/em> will work only under <em><strong>Windows<\/strong><\/em> 64 bit, I am checking for the correct environment before executing the code. Calling the <em><strong>DLL<\/strong><\/em> function is made possible by the <em><strong>&#8220;Declare Function&#8221;<\/strong><\/em> statement. The rest of the code is pretty straightforward.<\/p>\n<p>Here is the action handler for the <em><strong>&#8220;Fibonacci&#8221;<\/strong><\/em> button:<\/p>\n<figure id=\"attachment_2773\" aria-describedby=\"caption-attachment-2773\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2773\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/fibcode\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg\" data-orig-size=\"797,263\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097566&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Fibonacci Button Handler\" data-image-description=\"&lt;p&gt;Fibonacci Button Handler&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Fibonacci Button Handler&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg\" class=\"wp-image-2773\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg?resize=550%2C181&#038;ssl=1\" alt=\"Fibonacci Button Handler\" width=\"550\" height=\"181\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg?resize=300%2C99&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg?resize=768%2C253&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/FibCode.jpg?w=797&amp;ssl=1 797w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-2773\" class=\"wp-caption-text\"><strong>Fibonacci Button Handler<\/strong><\/figcaption><\/figure>\n<p>There is nothing else to do in the project. Let us <em><strong>&#8220;Build&#8221;<\/strong><\/em> the project now. <em><strong>Xojo<\/strong><\/em> takes a couple of seconds to generate the relevant files.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>The executable file is called <em><strong>&#8220;CallingLisp.exe&#8221;<\/strong><\/em>. We are not ready to run the program yet. Remember, we have our <em><strong>&#8220;foreign&#8221;<\/strong><\/em> code in a <em><strong>DLL<\/strong><\/em>. This <em><strong>DLL<\/strong><\/em> must be in the <em><strong>&#8220;Path&#8221;<\/strong><\/em> when we run our program. To keep things simple, I copied my <em><strong>DLL<\/strong><\/em> into the same directory as the <em><strong>EXE<\/strong><\/em> file:<\/p>\n<figure id=\"attachment_2774\" aria-describedby=\"caption-attachment-2774\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2774\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/generatedfiles\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg\" data-orig-size=\"1079,451\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097478&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Generated Files\" data-image-description=\"&lt;p&gt;Generated Files&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Generated Files&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles-1024x428.jpg\" class=\"wp-image-2774\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?resize=600%2C251&#038;ssl=1\" alt=\"Generated Files\" width=\"600\" height=\"251\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?resize=300%2C125&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?resize=1024%2C428&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?resize=768%2C321&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/GeneratedFiles.jpg?w=1079&amp;ssl=1 1079w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2774\" class=\"wp-caption-text\"><em><strong>Generated Files<\/strong><\/em><\/figcaption><\/figure>\n<p>The above shows all the files generated by <em><strong>Xojo<\/strong><\/em> compiler, along with the <em><strong>DLL<\/strong><\/em> I added.<\/p>\n<p>Let us run our program by double-clicking <em><strong>&#8220;CallingLisp.exe&#8221;<\/strong><\/em>. I enter two integers in the input fields and click the respective buttons. The following shows the output:<\/p>\n<figure id=\"attachment_2776\" aria-describedby=\"caption-attachment-2776\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2776\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/run1-3\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg\" data-orig-size=\"497,421\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097817&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Running the Program\" data-image-description=\"&lt;p&gt;Running the Program&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Running the Program&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg\" class=\"size-medium wp-image-2776\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg?resize=300%2C254&#038;ssl=1\" alt=\"Running the Program\" width=\"300\" height=\"254\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg?resize=300%2C254&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run1.jpg?w=497&amp;ssl=1 497w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2776\" class=\"wp-caption-text\"><strong>Running the Program<\/strong><\/figcaption><\/figure>\n<p>The good news is that <em><strong>Xojo<\/strong><\/em> code has successfully called my <em><strong>Lisp<\/strong><\/em> functions to calculate the outputs displayed.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>I quit the <em><strong>App<\/strong><\/em>\u00a0and run it again.<\/p>\n<figure id=\"attachment_2777\" aria-describedby=\"caption-attachment-2777\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2777\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2022\/04\/17\/calling-lisp-functions-from-xojo\/run3-3\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg\" data-orig-size=\"497,421\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1650097973&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Another Run of the Program\" data-image-description=\"&lt;p&gt;Another Run of the Program&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Another Run of the Program&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg\" class=\"size-medium wp-image-2777\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg?resize=300%2C254&#038;ssl=1\" alt=\"Another Run of the Program\" width=\"300\" height=\"254\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg?resize=300%2C254&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/04\/Run3.jpg?w=497&amp;ssl=1 497w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2777\" class=\"wp-caption-text\"><strong>Another Run of the Program<\/strong><\/figcaption><\/figure>\n<p>So, our program works perfectly!<span class=\"Apple-converted-space\">\u00a0Of course, this is a <em><strong>&#8220;toy&#8221;<\/strong><\/em> application and hence\u00a0<\/span>there is nothing to brag about it.<\/p>\n<p>What is nice is that <em><strong>Xojo<\/strong><\/em> makes it possible (and easy) to call <em><strong>&#8220;foreign&#8221;<\/strong><\/em> functions from existing libraries, thus making code reuse possible. And even for a <em><strong>newbie<\/strong><\/em>\u00a0like me, this didn&#8217;t take much effort! Over the next few weeks, I will be spending more time on <em><strong>Xojo<\/strong><\/em>. Stay tuned.<\/p>\n<p>Feel free to <a href=\"http:\/\/www.rangakrish.com\/downloads\/CallingLisp.zip\" target=\"_blank\" rel=\"noopener\"><em><strong>download<\/strong><\/em><\/a>\u00a0the <em><strong>Project<\/strong><\/em> file and related resources.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days ago, I purchased Xojo Pro commercial license. In case you haven&#8217;t heard about the product, Xojo\u00a0is a popular cross-platform development tool targeting Desktop, Web and iOS (Android is expected in the near future). It supports an Object-Oriented Basic language. It has been around for over 25 years and has been steadily gaining [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,17,318],"tags":[303,319],"class_list":["post-2765","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming","category-xojo","tag-lisp-dll","tag-xojo"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-IB","jetpack-related-posts":[{"id":3050,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/03\/16\/building-a-xojo-app-to-interact-with-openai-api\/","url_meta":{"origin":2765,"position":0},"title":"Building a Xojo App to Interact with OpenAI API","author":"admin","date":"March 16, 2023","format":false,"excerpt":"A few weeks ago I registered with OpenAI to access its services through API and created a secret Key for my use. I then decided to build a simple application to try out the \u201cChat\u201d and \u201cCompletion\u201d models. Since I have several tools at my disposal (RAD Studio, LispWorks, Allegro\u2026","rel":"","context":"In &quot;OpenAI&quot;","block_context":{"text":"OpenAI","link":"https:\/\/www.rangakrish.com\/index.php\/category\/openai\/"},"img":{"alt_text":"Initial Screen","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/03\/Initial-Screen-300x232.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2927,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/10\/20\/why-learn-lisp\/","url_meta":{"origin":2765,"position":1},"title":"Why Learn Lisp?","author":"admin","date":"October 20, 2022","format":false,"excerpt":"In the last article, I had shared my views on why programmers should learn Prolog, preferably as the first language. What language should one learn next? I strongly pitch for Lisp, to be precise, \u201cCommon Lisp\u201d. Lisp happens to be the second oldest (1958) programming language, only after Fortran (1957)!\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2645,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/12\/25\/calling-lisp-functions-from-d-language\/","url_meta":{"origin":2765,"position":2},"title":"Calling Lisp Functions from D Language","author":"admin","date":"December 25, 2021","format":false,"excerpt":"After exploring \"newLisp\" in the past few posts, I would like to start looking at the \"D Programming Language\"\u00a0(DLang). DLang\u00a0has been around since 2001. It was originally created by Walter Bright and later Andrei Alexandrescu joined the team in 2007. The main inspiration for DLang was C++, although it uses\u2026","rel":"","context":"In &quot;D Language&quot;","block_context":{"text":"D Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/d-language\/"},"img":{"alt_text":"Lisp Function Called from D","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2736,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/03\/19\/book-review-introducing-blockchain-with-lisp\/","url_meta":{"origin":2765,"position":3},"title":"Book Review: Introducing Blockchain with Lisp","author":"admin","date":"March 19, 2022","format":false,"excerpt":"Title: Introducing Blockchain with Lisp: Implement and Extend Blockchains with the Racket Language Author: Boro Sitnikovski Publisher: Apress Year: 2021 Blockchains are a hot topic these days and interestingly, I am getting involved in a project that uses Blockchain. Languages such as C++, Java, Go and Node.js are commonly used\u2026","rel":"","context":"In &quot;Book Review&quot;","block_context":{"text":"Book Review","link":"https:\/\/www.rangakrish.com\/index.php\/category\/book-review\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/03\/Blockchain-Book-300x251.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":70,"url":"https:\/\/www.rangakrish.com\/index.php\/2015\/11\/13\/aspect-oriented-programming-and-lisp\/","url_meta":{"origin":2765,"position":4},"title":"Aspect-Oriented Programming and Lisp","author":"admin","date":"November 13, 2015","format":false,"excerpt":"Aspect-oriented programming (AOP) is a popular approach to handle cross-cutting concerns in an application. Common examples of cross-cutting functionality are Logging, Error Handling and Transaction Management. AspectJ\u00a0is the original AOP extension created for Java in 2001.\u00a0AOP extensions have been developed\u00a0for some\u00a0other languages also. There are many good books and online\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Lisp Method Combination","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2015\/11\/Lisp-Method-Combination-1.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2015\/11\/Lisp-Method-Combination-1.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2015\/11\/Lisp-Method-Combination-1.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":245,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/05\/26\/constraint-propagation-in-picat\/","url_meta":{"origin":2765,"position":5},"title":"Constraint Programming in Picat","author":"admin","date":"May 26, 2016","format":false,"excerpt":"In my last post\u00a0I briefly described how we can use the Screamer Lisp library for constraint programming in music. Another language I have been hearing a lot about, in the context of constraint programming, is Picat, a Prolog-derived language. Although I am familiar with Prolog and have been a user\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Picat Program","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/05\/Picat-Program.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=2765"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2765\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=2765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=2765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=2765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}