; 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:
; 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
; 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))
; Display each filename in the list
For lsthead (ld) lstcset (ld) lstnext (ld)
put (lstcget (ld))
; Free the list.
; Function to type a file
; Print usage message if no pathname specified
If ne (argc() "1")
put ("Usage: type
; 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)
; Read and display each line of the file
While gt (read (path_fd buf) "0")
; Close the file and exit
; The windef.max file contains command definitions used in the calls
; to the window builtin function.
; Allocate new transient level so windef's can be freed
; 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
; Display a directory of user defined functions at startup
print ("The sample programs have been loaded. Try dir(), type() or showsine().")