C64-Wiki:Code Example

From C64-Wiki
Jump to: navigation, search

Remark: This article describes the BASIC-Command LOAD in BASIC V2 at the Commodore 64.

Typ: for example Statement
General Programming-Syntax: for example LOAD ["<filename>"] [,<device number>] [,<secondary number>]

description of the command for example: The BASIC-Command LOAD is used for loading program files (PRG) (also BASIC- or computer code programs) from datasette or diskdrive into the RAM-memory. That must be happend before a program can be editing or started and executed with the BASIC-Command RUN.

The device number is needed for the computer, which relaised the correct storage device:

  • datasette (device number 1)
  • diskdrives (device numbers 8-11, optional first diskdrive 8, second diskdrive 9, etc.)

When isn't used a device number, the computer uses the first device: datasette.

The filename loads the correct file. It can be used jokers like *, ? or $ Examples:

LOAD"*",8 loads the first file
LOAD"A*",8 loads the first file with A
LOAD"A?C",8 loads the first file with A.C. The joker ? is for any single char 
LOAD "$",8 loads the dircetory

With the secondary number knows the computer, which must be load a program.

,0 The program will be loaded to the Begin of BASIC-Memory (2049/$0801)
,1 The program will be loaded absolute. Needed for computer code programs.

When isn't used a secondary number, the computer uses the ,0.

Then the command LOAD is entered directly, all opend files will be closed and the BASIC-Command CLR will be executed in the background. By using LOAD in BASIC-Programs the stack don't deleted, but after loading another file, the BASIC-command RUN will be executed in the background.

A user can be easier work with datasette, to push the keys <SHIFT>+<RUN/STOP> together. After that he can be push the <PLAY> at the datasette and the first file will be searched. After a fews seconds the founded file will be viewed on screen with "FOUND Filename" and then loading in the RAM-memory. With the <SPACE>-key can be the file loading jump over. By loading a file from datasette the screen will be switched off, while by loading form another storage device the screen is normal.

The BASIC-errormessage "?FILE NOT FOUND" appears, then the filename didn't exists or isn't a program file.


(loads a program from the first diskdrive 8)
(loads a program absolute form the second diskdrive 9)
(loads a program with a charstring FILE$ absolute from datasette)
20 IF A=0 THEN A=A+1: LOAD "MUSIC",8,1
30 IF A=1 THEN A=A+1: LOAD "SPRITES",8,1
40 IF A=2 THEN A=A+1: LOAD "GRAPHIC",8,1
50 IF A=3 THEN A=A+1: LOAD "LEVEL1",8 (Remark: Link for the German C64-Wiki)