ExtractBasic: Extract or replace lines of Amiga Basic code

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Extract or replace lines of Amiga Basic code

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'AmigaBasic'
x[i]

## S3 replacement method for class 'AmigaBasic'
x[i] <- value

## S3 method for class 'AmigaBasic'
x[[i]]

## S3 replacement method for class 'AmigaBasic'
x[[i]] <- value

Arguments

x

An AmigaBasic class object from which specific lines need to be extracted or replaced.

i

In case of ‘[[’, an integer index, representing the line-number of basic code to be selected. In case of ‘[’: a vector of numeric indices. This index is used to select specific lines. Negative values will deselect lines.

value

A vector of character strings or an AmigaBasic class object that is used to replace the selected indices i. value should represent the same number of lines of code as the selected number of lines.

Details

Extract or replace specific lines in an AmigaBasic-class object.

Value

The extraction method returns an AmigaBasic object based in the lines selected with i. The replacement method returns an AmigaBasic object with the selected lines replaced with value.

Author(s)

Pepijn de Vries

See Also

Other AmigaBasic.operations: AmigaBasic.reserved(), AmigaBasicBMAP, AmigaBasic, as.AmigaBasicBMAP(), as.AmigaBasic(), as.character(), check.names.AmigaBasic(), names.AmigaBasic(), rawToAmigaBasicBMAP(), rawToAmigaBasic(), read.AmigaBasicBMAP(), read.AmigaBasic(), write.AmigaBasic()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 
## First generate a few lines of Basic code:
bas <- as.AmigaBasic(c(
  "LET a = 1",
  "a = a + 1",
  "PRINT \"a now equals\";a",
  "INPUT \"clear screen (y/n)? \", b$",
  "IF UCASE$(b$) = \"Y\" THEN CLS"
))

## Select only lines 4 and 5:
bas[4:5]

## use negative indices to deselect specific lines.
## deselect line 2:
bas[-2]

## replace line 2
bas[2] <- "a = a + 2"

## You can also use AmigaBasic class object as replacement
bas[2] <- as.AmigaBasic("a = a + 3")

## single lines can also be selected with '[['
bas[[2]]

## End(Not run)

AmigaFFH documentation built on Sept. 5, 2021, 5:22 p.m.