Path specifiers

Introduction

In order to read a teletext frame from file, or write to the user I/O file, you need a 'path'. This is the location where the file will be created.
It is not advised to specify a file using only the filename as there is no guarantee as to where the file could end up.

Unfortunately, the naming conventions between RISC OS and Windows are completely different, so you will need to either write system-specific code (and include a check to reject the wrong system) or write dual-system code.

 

Paths under RISC OS

Paths under RISC OS are best expressed using system variables. For specifics of path construction, please refer to your RISC OS user guide.

<Teletext$Pages> Where your teletext pages are stored. Usually "!Teletext.Pages".
<Teletext$Temp> Where teletext temporary files are placed; either within !Teletext or within Wimp$Scrap.
<Teletext$Script> Where your teletext scripts are kept. Usually "!Teletext.scripts".
<Teletext$Cache> Points to where your cache data is stored.
<Teletext$Config> The name of your Teletext configuration file (not a path).
<Teletext$Prefer> The name of your Teletext preferred pages file (not a path).

A valid path could therefore be something like:

filewrite("<Teletext$Temp>.outfile")

 

Paths under Windows

Windows does not offer anything like the same degree of flexibility as RISC OS system variables, so we fake a little bit of it. You can specify 'paths' in between hash characters at the start of a filename:
#PAGES# Where your teletext pages are stored. See below.
#APP# Where your WinTTX is installed.
#CACHE# Where your cache is stored, usually the same as "#APP#".
#TEMP# Your temporary folder; often "C:\Temp" or "C:\Windows\Temp" on older systems, but hidden away on a per-user basis on XP (etc).

A valid path could therefore be something like:

filewrite("#TEMP#\outfile.txt")

When WinTTX starts, it will look for:

  My Documents\Teletext pages
and if it does not exist, it will be created and set as the default path for saving frames.

The teletext script has a wider search, and will search in this order, stopping at the first that exists:

  My Documents\Teletext pages
  My Documents\Teletext frames
  <APPPATH>\Pages
  <APPPATH>

The application install path ('<APPPATH>') is, by default:

  C:\Program Files\HeyRick\WinTTX

 

Writing dual-system script

As discussed in the introduction:

It is possible to write scripts that work equally on both systems. To do so, you should take advantage of the differences between !Teletext which offers channel presets, and WinTTX that expects a UHF channel. This, requesting the channel preset number under WinTTX will always return "-1", as this code demonstrates:

set A to status(channel)
if (A ! -1) goto("riscoscode")

; this stuff is Windows code
[...blah blah - WinTTX specific stuff...]
go("continue")

.riscoscode
; this stuff is RISC OS code
[...blah blah - !Teletext specific stuff...]

.continue
; everybody meets back here

OvationPro and HTML do not care how their lines are terminated. Things are trickier with ASCII files as some software (such as Notepad) cannot cope with files where lines are not CRLF terminated.

In either case, you will need system-specific code at the start of the script (opening the output file) and at the end (RISC OS - assigning filetype; both - running the file). For ASCII you may need to insert <13> codes before <10>s for correct newlines.
My suggestion, therefore, is to use an integer variable (how about 'O' for OS?) which is set to a value for RISC OS, and something else for Windows. Then you can test, for example:

set O to 0
set A to status(channel)
if (A ! -1) set O to 1       ; 1 = RISC OS, 0 = Windows

if (O = 0) filewrite("#TEMP#\MyFile.txt")
if (O = 1) filewrite("<Teletext$Temp>.MyFile")

[...blah blah - some code...]

if (O = 0) filewritebyte(13) ; correct newline on either OS
filewritebyte(10)

[...blah blah - more code...]

fileclose()
if (O = 1) filetype("<Teletext$Temp>.MyFile", &FFF)

if (O = 0) execfile()
if (O = 1) oscall("%Filer_Run <Teletext$Temp>.MyFile")

if (O = 0) quit()
terminate()