<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Scripting on TurboVision</title>
    <link>https://turbovision.in6-addr.net/tags/scripting/</link>
    <description>Recent content in Scripting on TurboVision</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 21 Apr 2026 14:06:12 +0000</lastBuildDate>
    <atom:link href="https://turbovision.in6-addr.net/tags/scripting/index.xml" rel="self" type="application/rss&#43;xml" />
    
    
    
    <item>
      <title>Batch File Wizardry</title>
      <link>https://turbovision.in6-addr.net/retro/dos/batch-file-wizardry/</link>
      <pubDate>Fri, 05 Sep 2025 00:00:00 +0000</pubDate>
      <lastBuildDate>Mon, 09 Mar 2026 09:46:27 +0100</lastBuildDate>
      <guid>https://turbovision.in6-addr.net/retro/dos/batch-file-wizardry/</guid>
      <description>&lt;p&gt;DOS batch files have no arrays, no functions, and barely have variables.
Yet people built menu systems, BBS doors, and even games with them.&lt;/p&gt;
&lt;p&gt;The trick is &lt;code&gt;GOTO&lt;/code&gt; and &lt;code&gt;CHOICE&lt;/code&gt; (or &lt;code&gt;ERRORLEVEL&lt;/code&gt; parsing on older DOS).
Combined with &lt;code&gt;FOR&lt;/code&gt; loops and environment variable manipulation, you can
create surprisingly interactive scripts. We build a file manager menu
in pure &lt;code&gt;.BAT&lt;/code&gt; that would feel at home on a 1992 shareware disk.&lt;/p&gt;
&lt;p&gt;The charm of batch scripting is that constraints are obvious. You cannot hide
behind abstractions, so control flow has to be explicit and disciplined. A
good &lt;code&gt;.BAT&lt;/code&gt; file reads like a state machine: menu, branch, execute, return.&lt;/p&gt;
&lt;h2 id=&#34;patterns-that-still-hold-up&#34;&gt;Patterns that still hold up&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Use descending &lt;code&gt;IF ERRORLEVEL&lt;/code&gt; checks after &lt;code&gt;CHOICE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Isolate repeated screen/header logic into callable labels.&lt;/li&gt;
&lt;li&gt;Validate file paths before launching external tools.&lt;/li&gt;
&lt;li&gt;Keep environment variable scope small and predictable.&lt;/li&gt;
&lt;li&gt;Always provide a safe &amp;ldquo;return to menu&amp;rdquo; path.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These rules prevent the classic batch failure mode: jumping into a dead label
or leaving the user in an unexpected directory after an error.&lt;/p&gt;
&lt;h2 id=&#34;building-a-useful-menu-shell&#34;&gt;Building a useful menu shell&lt;/h2&gt;
&lt;p&gt;A practical structure is a top menu plus focused submenus (&lt;code&gt;UTIL&lt;/code&gt;, &lt;code&gt;DEV&lt;/code&gt;,
&lt;code&gt;GAMES&lt;/code&gt;, &lt;code&gt;NET&lt;/code&gt;). Each action should print what it is about to run, execute,
and then pause on failure. That tiny bit of observability saves debugging
time when scripts grow beyond toy examples.&lt;/p&gt;
&lt;p&gt;Batch is primitive, but that is exactly why it teaches sequencing, error
handling, and operator empathy so well.&lt;/p&gt;
&lt;p&gt;Related reading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://turbovision.in6-addr.net/retro/dos/tp/turbo-pascal-in-2025/&#34;&gt;Writing Turbo Pascal in 2025&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://turbovision.in6-addr.net/retro/dos/c-after-midnight-a-dos-chronicle/&#34;&gt;C:\ After Midnight: A DOS Chronicle&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
