1
0
mirror of https://github.com/pkimpel/retro-220.git synced 2026-02-11 18:45:34 +00:00
Files
pkimpel.retro-220/software/tools/Xlate-Card-PT.wsf
Paul Kimpel 28eae3bfdd Commit support for paper-tape/TTY I/O in BALGOL and run-time.
1. Implement paper-tape/TTY versions of compiler INPUTMEDIA and
OUTPUTMEDIA routines, and the run-time REED and RITE routines.
2. Create Generator callout deck to make a compiler tape containing
paper-tape/TTY support.
3. Create a compiler tape containing paper-tape/TTY support.
4. Create a paper-tape compiler callout bootstrap program.
5. Correct address for NUMB in Generator source to match the address in
the compiler's Overlay module.
6. Create corrected Generator tape (must be used to create compilers
with paper-tape/TTY support).
7. Add option to produce Generator INPUTMEDIA/OUTPUTMEDIA object card
decks to BAC-Assembler and GEN-Assembler.
8. Create Xlate-Card-PT.wsf utility to convert card-image files to
retro-220 paper-tape image files.
9. Create paper-tape versions of example BALGOL programs.
2018-10-23 13:15:31 -07:00

128 lines
3.2 KiB
XML

<?XML version="1.0"?>
<package>
<job id="Xlate-Card-PT">
<reference object="Scripting.FileSystemObject" />
<script language="VBScript">
<![CDATA[
Option Explicit
'-----------------------------------------------------------------------
' retro-220 Xlate-Card-PT.wsf
' Copyright (c) 2018, Paul Kimpel,
' Licensed under the MIT License, see
' http://www.opensource.org/licenses/mit-license.php
'-----------------------------------------------------------------------
' VBScript to reformat card-image files to the paper-tape format used by
' the retro-220 emulator.
' Uses Scripting Runtime FileSystemObject.
' Parameters:
' Name of card-image file (required).
' Number of words per paper-tape record (5 char/word) (optional,
' defaults to 14).
' Name of resulting retro-220 file (optional, by defaults to the name
' of the card-image file with ".pt" replacing the orginal file
' name extension.
'-----------------------------------------------------------------------
' Modification Log.
' 2018-10-22 P.Kimpel
' Original version, cloned from retro-220 Mahon-PT-Xlate.wsf.
'-----------------------------------------------------------------------
Const charsPerWord = 5
Const defaultSuffix = ".pt"
Const defaultWordsPerRec = 14
Dim args
Dim cardFile
Dim cardName
Dim charsPerRec
Dim fso
Dim ptFile
Dim ptName
Dim wordsPerRec
'---------------------------------------
Sub ReformatPaperTape
'Creates the retro-220 paper-tape file from the card-image file.
Dim code
Dim count
Dim line
Dim word
Dim x
count = 0
word = ""
Do While Not cardFile.AtEndOfStream
line = cardFile.ReadLine
count = Len(line)
If count > charsPerRec Then
line = Left(line, charsPerRec)
Else
Do While count < charsPerRec
line = line + " "
count = count+1
Loop
End If
For x = 1 To charsPerRec Step charsPerWord
ptFile.WriteLine "2" & Mid(line, x, charsPerWord)
Next
Loop
End Sub
'---------------------------------------------------------------
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
wordsPerRec = defaultWordsPerRec
Set args = WScript.Arguments
If args.Count < 1 Then
MsgBox "Must supply at least the name of the assembler-encoded file."
WScript.Quit 9
Else
cardName = Trim(args.Item(0))
If args.Count > 1 Then
If IsNumeric(args.Item(1)) Then
wordsPerRec = CLng(args.Item(1))
Else
MsgBox "Second parameter must be number of words."
WScript.Quit 9
End If
End If
If args.Count > 2 Then
ptName = Trim(args.Item(2))
Else
ptName = fso.BuildPath(fso.GetParentFolderName(cardName), fso.GetBaseName(cardName)) & defaultSuffix
End If
End If
Set args = Nothing
charsPerRec = wordsPerRec*charsPerWord
'-- Main Line --
If Not fso.FileExists(cardName) Then
MsgBox "Card-image file does not exist: " & vbCrLf & cardName
Else
Set cardFile = fso.OpenTextFile(cardName, ForReading, False)
Set ptFile = fso.CreateTextFile(ptName, True, False)
ReformatPaperTape
ptFile.Close
Set ptFile = Nothing
cardFile.Close
Set cardFile = Nothing
MsgBox "retro-220 paper-tape file created: " & vbCrLf & ptName
End If
Set fso = Nothing
WScript.Quit 0
]]>
</script>
</job>
</package>