Skip to contents

Read an AmigaBasic() script from its binary format.

Usage

read.AmigaBasic(file, disk = NULL, ...)

Arguments

file

A character string of the filename of the Amiga Basic file to be read.

disk

A virtual Commodore Amiga disk from which the file should be read. This should be an amigaDisk() object. Using this argument requires the adfExplorer package. When set to NULL, this argument is ignored.

...

Currently ignored

Value

Returns an AmigaBasic() class object read from the file.

Details

Normally Amiga Basic code is stored encoded in a binary format (rawToAmigaBasic()). This function reads the binary data from a file (which can be stored on a virtual disk (amigaDisk())) and converts in into an AmigaBasic() class objec.

Author

Pepijn de Vries

Examples

if (FALSE) {
## First create an AmigaBasic file
write.AmigaBasic(as.AmigaBasic("PRINT \"Hello world\""),
                 file.path(tempdir(), "helloworld.bas"))

## Now let's read the same file:
bas <- read.AmigaBasic(file.path(tempdir(), "helloworld.bas"))
}

## There's also a demo file included with the package
demo.bas <- read.AmigaBasic(system.file("demo.bas", package = "AmigaFFH"))
demo.bas
#> OPEN "ball.shp" FOR INPUT AS 1
#> OBJECT.SHAPE 1,INPUT$(LOF(1),1)
#> CLOSE 1
#> OBJECT.X 1,320
#> OBJECT.Y 1,127
#> OBJECT.ON 1
#> OBJECT.START
#> LET t=0
#> PRINT "Press any key to continue..."
#> WHILE INKEY$ =""
#>   OBJECT.X 1, 320+200*SIN(t)
#>   OBJECT.Y 1, 127+100*COS(t)
#>   t=t+.001
#> WEND
#> SCREEN 1,320,256,3,1
#> WINDOW 1,"Bob Window",(0,0)-(297,242),31,1
#> PALETTE 0,1,1,1
#> PALETTE 1,.1333333,.4,.7333333
#> PALETTE 2,.2,.4,.7333333
#> PALETTE 3,.2666667,.4666667,.6666667
#> PALETTE 4,.4666667,.5333333,.6
#> PALETTE 5,.6,.6,.6
#> PALETTE 6,.6666667,.6666667,.6666667
#> PALETTE 7,.7333333,.7333333,.7333333
#> FOR i% = 0 TO 7
#>   COLOR i%
#>   AREA (i%*10, 30)
#>   AREA STEP (10, 0)
#>   AREA STEP (0, 10)
#>   AREA STEP (-10,0)
#>   AREAFILL
#> NEXT i%
#> OPEN "r_logo.shp" FOR INPUT AS 1
#> OBJECT.SHAPE 2,INPUT$(LOF(1),1)
#> CLOSE 1
#> OBJECT.X 2,160
#> OBJECT.Y 2,127
#> OBJECT.ON 2
#> PRINT "Press any key to stop..."
#> WHILE INKEY$=""
#>   OBJECT.X 2, 160+100*SIN(t*.3)
#>   OBJECT.Y 2, 127+50*COS(t)
#>   t=t+.01
#> WEND
#> SCREEN CLOSE 1
#> END