Category : Miscellaneous Language Source Code
Archive   : MAX.ZIP
Filename : SAMPLE.MAX

Output of file : SAMPLE.MAX contained in archive : MAX.ZIP
; If you don't want this file to be loaded as part of Max's
; initialization, remove it from config.max.
; The structured preprocessor definitions such as:
; Function Begin EndFunction and
; For EndFor
; are located in block.max. This file is specified in config.max
; and is loaded during Max initialization.

; Function to print a directory listing

Function dir

; If no name specified then display a list of all regular
; files in the current directory.

If eq (argc() 0)
set (name "*.*")

; Otherwise use the pathname and wildcard string supplied
; by the user.

set (name argv (1))

; Allocate a list and read the directory into it and sort it.

set (ld dirlst (name))
lstsort (ld)

; Display each filename in the list

For lsthead (ld) lstcset (ld) lstnext (ld)
put (lstcget (ld))

; Free the list.

lstfre (ld)


; Function to type a file

Function type

; Print usage message if no pathname specified

If ne (argc() "1")
put ("Usage: type ")
exit ()

; Get pathname and open file

set (path argv(1))
set (path_fd open (path "r"))

; Print error message if file cannot be opened

If lt (path_fd 0)
put ("Cannot open " path)
exit ()

; Read and display each line of the file

While gt (read (path_fd buf) "0")
put (buf)

; Close the file and exit

close (path_fd)


; The windef.max file contains command definitions used in the calls
; to the window builtin function.

Function showsine

; Allocate new transient level so windef's can be freed

tpush ()
tset ()
$include ("windef.max")

; Define a new window for sine wave

window (WLocation 5 10 19 70) ; top=5 left=10 bottom=10 right=70
window (WStyle fmhex (0x70)) ; inverse video
window (WBorder 2) ; double line border
window (WTitle " Sine Wave ") ; give window a title
set (wd window (WOpen)) ; open window and save descriptor (wd)

; Plot sine wave from 0 to 2*pi

set (two_pi mul (3.14 2))

For set (x 0) lt (x two_pi) set (x add (x 0.2))

set (y sin (x)) ; set y to sine of x
set (y mul (y 20)) ; scale for display
set (y add (y 30)) ; in center of window
set (buf strcat (strcpy (" " y) "*\n")) ; format string
window (WSend wd buf) ; write to window


window (WSend wd "\nUse arrow keys to view sine wave. Press return when done.")
window (WReceive wd buf)

window (WClose wd)
window (WRefresh 0)
window (WRefresh 1)

; Clear the storage for this function and windef replacement text

tclear ()
tpop ()


; Display a directory of user defined functions at startup

udfdir ()

print ("The sample programs have been loaded. Try dir(), type() or showsine().")

  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : MAX.ZIP
Filename : SAMPLE.MAX

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: