Welcome to the Lingo scripts page. The scripts included on this and all following pages may be freely used by one and all. Please note I take no legal responsibility nor liability should they fail to work correctly. All these scripts were produced using Director 4.04 and may well not work in later versions of Director. These scripts range from the basic ( rollovers, castmember swaps, puppeting, custom cursors) to the more complex (Miaws, flaging events, X -Objects ). If you've been playing my shockwave games and wish to see the scripting they appear on page 3 As you'll see these pages are notes they've been neither tidyed nor maximised for web presentation. Let me outta here!

 

script to attach cursor to mouse;
 on exitFrame
  cursor 200
  -- update the cursor location to the mouse
  set the locH of sprite 48 = the mouseH
  set the locV of sprite 48 = the mouseV
 end
--------------------------
One to try ! Improves cursor reaction to user input
 on exitFrame
  cursor 200
  go the frame
 on idle
  -- update the cursor location to the mouse
  set the locH of sprite 48 = the mouseH
  set the locV of sprite 48 = the mouseV
 end
==========================================================================================
SCRIPT TO CHANGE ITEM ON MOUSE UP;
(SCORE SCRIPT)
1)
 on exitFrame
  go the frame
 end
-----
2) ITEM TO CHANGE THIS CASE A DOT,
CHANGING ELEMENT COLOUR.(SCORE SCRIPT OF SPRITE 2)
3)
 on mouseUp
  change
 end
-----
(MOVIE SCRIPT)
4)
 on change
  puppetSprite 1, TRUE
  set the foreColor of sprite 1 to ¬
   random (256) -1
  updateStage
 end
==========================================================================================
SCRIPT TO CHANGE PUPPET CAST MEMBERS; OBJECT TO SWAP CAST MEMBER 1 FOR 2
(SCORE SCRIPT)
1)
 on exitFrame
  set the puppet of sprite (1) to TRUE
 end
----------------------------
(SPRITE SCRIPT)
2)
 on mouseUp
  set the castNum of sprite (1) to 2
 end
---------------------
(SCORE SCRIPT)
3)
 on exitFrame
  go the frame
 end
==========================================================================================
(FRAME SCRIPT TO RETURN TO ORIGINAL PATH)
 on mouseUp
  play done
 end
-----
 on exitFrame
  go to "tunnel" of movie "dali four"
 end
===========================================================================================
ROLLOVER SCRIPT
 on startmovie
  puppetsprite 1, TRUE
  puppetsprite 2, TRUE
 on enterframe
  if rollover (1) then
   set the forecolor of sprite 1 = 56
    updatestage
  else
   set the forecolor of sprite 1 = 250
  end if
   if rollover (2) then
   set the forecolor of sprite 2 = 100
   updatestage
  else
   set the forecolor of sprite 2 = 7
   updatestage
  end if
 end
==========================================================================================
CURSOR CHANGE OVER RECTANGLE
 on startmovie
  puppetsprite 33, TRUE
  puppetsprite 2, TRUE
  puppetsprite 5, TRUE
 on exitFrame
  cursor 200
  -- update the cursor location to mouse
  set the locH of sprite 33 = the mouseH
  set the locV of sprite 33 = the mouseV
  updateStage
  if rollover (1) then
   set the castnum of sprite (33) to 2
  end if
 end
==========================================================================================
INSTRUCTION TO PLAY A DIFFERENT MOVIE
 on mouseUp
  play movie "gallery"
 end
----------------------------------------
GO TO THE MARKER
 on exitFrame
  go to "left"
 end
--------------------------------
 on mouseUp
  quit
 end
==========================================================================================
TO CONTROL SOUND LEVEL E.G. DOWN
 on exitFrame
  set the soundLevel to 7
 end
-------
 on exitFrame
  set the soundLevel to 5
 end
------
 on exitFrame
  set the soundLevel to 3
 end
--------------------------------
SET THE SOUND AT THE BEGINING OF A MOVIE
 on volumeup
  if the soundLevel < 7 then
   set the soundLevel to the soundLevel = 1
 end if
 end volumeup
 on volumeDown
   if the soundLevel > 1 then
   set the soundLevel to the soundLevel -1
 end if
 end volumeDown
---------------------------------
To play sound from source file not in a director movie
 on startmovie
  set the soundlevel to 7
  sound playfile 2,"HD:Docuements:title:shr.DirCast:wild thing"
 end
==========================================================================================
LOCK CURSOR IMAGES / PLAY SOUND ON MOUSE UP
 on enterframe
  cursor 200
  if the locv of sprite 33 < 435 then
   set the visible of sprite 33 to false
    set the visible of sprite 34 to true
   set the visible of sprite 35 to false
  else
   set the visible of sprite 33 to true
   set the visible of sprite 34 to false
  end if
   set the loch of sprite 33 to the mouseh
   set the locv of sprite 33 to the mousev
   set the loch of sprite 34 to the mouseh
   set the locv of sprite 34 to the mousev
    set the loch of sprite 35 to the mouseh
   set the locv of sprite 35 to the mousev-50
 on mouseUp
  set the visible of sprite 35 to true
  puppetsound "gunshot.wav"
  updatestage
  set the visible of sprite 35 to false
  updatestage
 end
=========================================================================================
Script to change cursor sprite when rolled over a particular location
 on exitFrame
  cursor 200
   -- update the cursor location to the mouse
  set the loch of sprite 2 = the mouseh
  set the locv of sprite 2 = the mousev
  updatestage
  if rollover (1) then
   set the visible of sprite 2 to false
   set the visible of sprite 3 to true
   -- update the cursor location to the mouse
   set the loch of sprite 3 = the mouseh
   set the locv of sprite 3 = the mousev
   set the constraint of sprite 3 to 1
  else
   set the visible of sprite 2 to true
   set the visible of sprite 3 to false
   updatestage
  end if
   updatestage
   go to the frame
 end
===========================================================================================
Script to puppet through a picture show using three buttons
 on exitframe
  -- sprite 14 will be used to show castmembers in our show
  set the puppet of sprite 14 to true
 end
---------------------------
( next button script)
 on mouseup
  -- Advance to the next slide
  set b = the castNum of sprite 14
   set b = b + 1
  if b <= 12 then
   set the castnum of sprite 14 to b
   puppetsound "click" true
  end if
 end
----------------------------
( previous button script)
 on mouseup
    -- Show the previous slide
   set b = the castnum of sprite 14
  set b = b -1
  if b > 0 then
   set the castnum of sprite 14 to b
   puppetsound "click" true
  end if
 end
----------------------------
( main button script that returns you to the point of orgin)
 on mouseup
  set the puppet of sprite 14 to false
  puppetsound "click" true
  go to "begin"
 end
----------------------------
This last script changes the slde show now the slides suffle through to the begining repeating themslves endlessly.
 on mouseUp
   -- Advance to the next slide
  set b = the castNum of sprite 14
  set b = b + 1
  if b <= 12 then
   set the castNum of sprite 1 to b
  else
   set the castNum of sprite 14 to 1
  end if
 end
=========================================================================================

--Mouse Location

 on startMovie
  set the mouseUpScript to "HandleMouse"
  installMenu A13
 end startMovie

 on HandleMouse
   --MH and MV are local variables; MV = Vertical mouse position; MH = Horizontal mouse position
  --fields "MH" and "MV" are likewise representations of the horizontal and vertical values
   --note: in general its a good idea to save the mouseH and mouseV into variables as soon as
  --possible since they are not static values
  put the mouseH into MH
  put the mouseV into MV
  put "Horizontal:" & " " & string(MH) into field "MH"
  put "Vertical:" & " " & string(MV) into field "MV"
 end HandleMouse

 on MovieDone
  global gSubMovies
  if gSubMovies = true then play done
  ;else   quit
 end

=========================================================================================
Movie in a window Commands;=======
[ NOTE MOVIES IN A WINDOW DO NOT GET PURGED FROM MEMORY WHEN FINISHED PLAYING THEY MAY NOT BE IN VIEW BUT THEY ARE STILL RUNNING IN RAM. TO CLEAR THEM FROM RAM USE THE FOLLOWING COMANDS]
 on stopmovie
  forget window "running"
 end
[CLOSE OR HIDE WINDOW WILL NOT PURGE MOVIES FROM RAM]
TO START A MOVIE
open window "running"
 on mouseup
  play movie "running man"
 end
MOUSE UP COULD BE CONVERTED TO
 ON ENTERFRAME
=======================================================================================

Script to controll window shape
 on mouseUp
  set the windowtype of window "Running" to 2
  -- this sets the window to a plain box
  set the rect of window "running " = rect¬ (100, 100, 260, 220 )
  open window "Running"
 end
=========================================================================================
WINDOW ID CODES;
 ID code 1, the alert box style window
 ID code 2, the plain box style window
 ID code 3, the plain box with drop shadow style window
 ID code 4, the docuement window without zoom box
 ID code 8, the docuement window with zoom box
 ID code 16, the curved window box
=======================================================================================
Comand to send the root movie to look for another placed in a different location
 on mouseUp
  play movie "Hard Disk:new home:jumping demo"
 end
--hard disk ( where the movie located ;new home ( the file movie resides in ;jumping demo (the name of the movie
====================================================
Other movie notes
To edit movies in director place them frame by frame in the score till they finish playing delete the unwanted section then turn them to quicktime movies. Use the ciepak option to reduce the size of each movie file e.g. a 1mg movie can be reduced to 540k.
----------------------------------------------continued
the finished movie can now be placed in one frame of the score To ensure the movie plays correctly select the tempo channel in the score and selct the radio button finish playing movie/ sound.
----------------------
Qt movies need their frame rates adjusting to ensure transistions appear in the movie as they do in a director file. This reqwuires some experimentation - sugested size 1 frame per second playback with a duration chunk size of 10 for transistion 51.
===================================================

Script to change the color depth of monitor
 on startmovie
  golbal userdepth -- this declares the colordepth a universal forcing
  --director to retains this information in ram untill some later date
  --when this varible can be recalled for further use
  put the colordepth -- this notes the monitors current settings
  put the colordepth into userdepth
  set the userdepth = 8 -- sets the depth to 256, 16 would be thousnds of colors
 end
a startmovie script was used to change the monitor depth an end movie script is used to tidy things up and return the monitor to it's original settings.
 on stopmovie
  guserdepth
  put the colordepth = userdepth
 end
===================================================
General Notes re - Director
Property; An aspect of a sprite we can change with lingo i.e. forecolor backcolor loch locv, properties always start with ‘the’.Properties = Atributes properties can contain both the question and answer : so ..... go to the frame = which frame? the current frame.
Further exsamples;
the castnum = the number of the cast in the sprite channel
forecolor = 8 bit
backcolor (must be 1 bit castmember) is the white part of the image
LocV LocH
the blend = transparent
the visible
Variable; A ‘box’ to hold a changing value or string. If the information needs to held over a period of time it needs to be a Global.
Event handler; A physical action that starts all lingo scripts i.e. on mouseup, on mousedown, exitframe, idle, startmovie, stopmovie.
[ Handler; name given to a piece of code - it's called by it's handle - a bit like a variable - e.g. both handler & variable names are arbitary i.e. anything other than a lingo word. These should be placed in a moviesript and should always be one word as in ‘myhandler’. Certain handlers can only work in a movie script.
Put and Set;
set changes something - the forecolor loch locv
put collects data and informs you of that data i.e. put the time - will tell you the current time.
exsample;
Put the time into wibble
into = create while wibble is the variable created
If you asked ‘put wibble’ you'll get the answer of the time the time was stored into wibble.
======================================================
Flag script;
 on exitFrame
  global flag
  go the frame

  set the puppet of sprite 2 to true
  set the puppet of sprite 3 to true
  set the puppet of sprite 4 to true
  if rollover(2) then
   Set the castNum of sprite 2 to 3
  else
   Set the castNum of sprite 2 to 6
  end if
  if rollover(3) and flag = 0 then
   set flag = 1
   set myVar = random(3)
  if myVar = 1 then
   Set the castNum of sprite 3 to 3
  else
  if myVar = 2 then
   Set the castNum of sprite 3 to 3
  else
  if myVar = 3 then
   Set the castNum of sprite 3 to 7
   go "On Blue"
  end if
 end if
end if
end if

  if not(rollover(3)) then
   Set the castNum of sprite 3 to 7
   set flag = 0
    put flag
  end if

 end
======================================================
Repeat Loop (scripts to run in my movie;!)
 on myhandler
  if the castnum of sprite 48 < 503 then
   set the castnum of sprite 48 = ¬
the castnum of sprite 48 + 1
  end if
  if the castnum of sprite 48 = 503 then
   set the castnum of sprite 48 = 500
  end if
  set the loch of sprite 48 = the mouseh
  set the locv of sprite 48 = the mousev
  updatestage
 end
===========
 on exitFrame
  set the visible of sprite 48 to true
  cursor 200
  --update cursor location to the mouse
  myhandler
   if rollover (2) then
    set the visible of sprite 48 to false
    set the visible of sprite 47 to true
    -- update the cursor location to the mouse
    set the loch of sprite 47 = the mouseh
    set the locv of sprite 47 = the mousev
    set the constraint of sprite 47 to 2
    else
    set the visible of sprite 48 to true
    set the visible of sprite 47 to false
    updatestage
   end if
   go the frame
 end

===============================
Repeat loops;
Repeat loops can be used in place of puppeting to good effect.The conventional approach is;
 on startmovie
  puppetsprite 1, true
  end
An alternative method is to use the repeat loop.
  Repeat with i = 1 to 5
(where i is the variable, it dosen't have to be i, it could be a, or anything. Here i is the variable that holds the numbers 1 to 5, - or 1 to 100 for that matter - these numbers run sequencially 1 through to 5. So to reverse the sequence your code would look like this; Repeat with k = 5 down 1)
 Repeat with j = 21 to 25
  set the castnum of sprite 1 to i
  updatestage
 end repeat
( All repeats must have an end repeat just as if's need end if's )
 on exitframe
 Repeat with i = 1 to 5
 if rollover (i) then
  set the castnum of sprite i =i
 else
  set the castnum of sprite i = 6
 end if
 end repeat
  go the frame
 end

( The above is as much character transposition as anything else, therefore cast members have to be related e.g.if the reverse of sprite 1 is castnum 20
then i = i + 20. Where can you use repeats in; movie scripts, exit/enterframe scripts
Exsample:  on startmovie       on exitframe
  Repeat with i = 1 to 5           Repeat with i = 1 to 5
  puppetsprite i, true               if rollover (i) then
  end repeat                      set the castnum of sprite i =i
 end                         else
                              set the castnum of sprite i = 6
                              end if
                               end repeat
                                go the frame
                                end)
====================================
Working Repeat exsample here six castmembers are being substituted on rollover using repeatloops and puppetting. the startmovie handler sets it up while the exit frame executes the changes:
 on startmovie
  ;repeat with i = 4 to 9
   --castmembers 4 to 9 are now in the variable i
   puppetsprite i, true
  end repeat
 end

------------
 on exitFrame
  repeat with i = 4 to 9
   if rollover (i) then
    -- 4 to 9
    set the castnum of sprite i = i+10
     -- transposes castmembers e.g. castnum 4 add 10 gives castnum 14
   else
    set the castnum of sprite i = i
   end if
  end repeat
  go to the frame
 end
====================================
Repeat While; Repeat while < test condition> (sets a test condition exsample;
 on exitframe                          Repeat while the mousedown
  if rollover sprite (1) then                 set the loch of sprite 1 = the loch
   repeat with i = 11 to 16                  of sprite 1 + 1
   set the castnum of sprite 1 to i             updatestage
   set n = the timer + 7                   end repeat
   -- setting timer N 60 + 7 ticks            -- while mousedown move sprite
   -- 60 ticks to a second                 -- by 1 pixel across stage
   -- starttimer resets timer to 0
   repeat while n > the timer
   -- still do this till timer adds 60 + 7             --to put the sprite where the
   nothing                             -- mouse is
   end repeat                             put the mouseh
   updatestage                             put the mousev into y
  end repeat                              set the locv of sprite 3 = y
  end if
  go the frame
 end)
====================================
Text sprite's or Fields;Strings can be moved between variables scripts and other fields. put "hello world" into field 6
put "hello world" into field "greeting"
put gvariable into field "greeting"
put field "source" into field "greeting"
We can break fields down into smaller chunks:
put line 1 of field "greeting" (line length is determined by entering a return)
put line 1 to 2 of field "greeting"
put word 1 to 4 of field "greeting" (words don't count spaces)
put char 2 to 8 0f field "greeting" (spaces between words are counted as charaters)
put item 1 of field "greeting" ( an item is anything between " ")
When working with fields it is usually best to allocate castmembers names rather than numbers. By using names as opposed to numbers any change is the cast will not affect your fields as they are called by name rather than a number. Characters are the smallest chunks while lines are the largest.
Line N to N of field line n of filed
word n to n word n of
char n to n char n of
item n to n item n of
put word 4 of line 2 of filed "result" -- puts the forth word of line 2 into the field called result.
put the number of lines in field "hutch" into x
put line x of field "different"
the number of char in
the number of items in
the number of words in
put "hello world" into field "result" -- doing this would replace what ever already resided in field result. to avoid this.
put "hello' after line 1 of field "result -- places the word after line one
put "hello" before line 1 of -- places the word before line one
If the lines of a character don't exist yet they'll be createdas blank char's or lines.
put "wibble"(username)&"wobble"(userscore) into field "wibble wobble"(score)
The ampersand -&- sticks words and strings togather. Using double ampersands && concantes.So in the wibble wobble exsample used above your field would look like this --jim180. Concanting using the double ampersand would add aspace between jim and the score 180.
put the number of lines in field "track" into x
puteframe into line x +1 of field "track"
put the frame &return after field 'track"
To get quote marks you need the ampersand and the word qoute -- &quote, gives "
Fields can be linked to mouse up scripts e.g. on mouseup
put the time && the date into field "other"
put quote& "david was here"&quote into field "result"
To controll the appearance of text:
set the textfont of field "name" to "times"
set the textsize of field "name" to "18"
set the textstyle of field "name" to "plain" or "p" ("bold" "b", "italic" "i" )
set the textalign of field "name" to "left" or "right" or "center"
=======
test for machine: put the machinetype into test
if test = 256 then
256 is an IBM everything else is a mac.
================================================================
Applescripts:
aim to open jiggsaw puzzle and replace exsisting pic with one of my chosing. To change the settings to hard and to be launched run and shut down from director 4
tell application "Finder"
 activate
 select startup disk
 open selection
 select folder "puzzles" of startup disk
 open selection
 select file "Jigsaw Puzzle" of folder "puzzles" of startup disk
 open selection
end tell
tell application "Finder"
 activate
 select startup disk
 open selection
 select folder "completed tunnels" of startup disk
 open selection
 select file "Jigsaw Puzzle" of folder "completed tunnels" of startup disk
 open selection
end tell
tell application "Finder"
 activate
 select file "Jigsaw Puzzle" of folder "completed tunnels" of startup disk
 open selection
end tell
Applescript and director : Director will respond to activate, tell, and"do script" commands sent from within the Apple Script Editor. With director set to Animate In Backround (using the Prefs in the file menue) This can happen in real time. Exsample;
tell apllication "diretor 4.0"
 activate
 do script "set myobj = file IO (mNew, ?read, TEXT)"
end tell
Director 3.11 introduced support for two versatile AppleEvents: "do script" (event "dosc" of type "misc") and "evaluate" (event 'eval" of type "misc").The former event, when sent to director, will execute any lingo command or custom handler. The latter will return the value of any variable, including textfields. Director does not have a native dway of sending AppleEvents to other applications. There are various flavours of "send AppleEvents" type of XCMDS which can be used instead. Director can also activate premade AppleScripts that have been saved as run only applications, by using the standard lingo open command.This saving option is available in the standard AppleScript Editor. By activating an applescript that has been saved as a application we can have director send complesx suites of raw AppleEvents to other applications. This is a way to use the full range of AppleScript capabilities to communicate with other programs.
There is a fly in the ointment; AppleScript requires a "Scripting Dictionary"-- a resource of type AETE to be able to figure out what it can tell applications to do. Director doesn't have an AETE resource. But it is possible to take tha AETE resource found in Otto's Goodies on the Mediabook CD rom open it with ResEdit, change the string "WILD" into "MMDR" to make it work with Director, and insert into a copy of the Director application. This gives AppleScript what it needs to talk to Director.
To see how scriptable an application is open the Applescript Editor and use the open Dictionary command on it. AppleScript can send "do script" commands to an unaltered copy of Director, but it will need an AETE resource in order to "evaluate" and return a term. This combination can be used to have Director retrieve values from a filemaker databases; to have filemaker send lingo commands to director; and to have director control Apple's Scriptable Text Editor. You can also send AppleEvents to Director from applications that can send "miscdosc" and "misceval" and other standard AppleEvents.
===================================
openDA DAname
Description
This command opens the desk accessory specified by DAName, which is the menu item name or an expression that yields the menu item name of any desk accessory installed in the computer.
Related topics: closeDA command
If the openDA command fails to locate the specified file, you will hear a beep but no error message will be displayed.
=================================
Menus: are a two part affair 1) the first part is lingo: installMenu cast "castname" or if the castmember was no 16 then; installMenu 16. Usually menus are intialised in the sartmovie script. The installmenu keyword refers to a text cast member, where the menue is stored. 2) A text cast member cotains the menu itself, be aware that its a text field as it behaves like a string: spaces, capitals, etc count.
Text castmember director 4.0
menu: - makes anew menu ---> FILE EDIT FONT
menu: @ gets you the apple menu logo
About my movie would be represented as:
/A} makes a keyboard short cut e.g. command A. So the menu will now look like this
Apple logo About my movie, command A &Mac197; go about ( the &Mac197; {option x} makes the following lingo instruction invisble In the moviescript you'd have a handler;
on goabout
go "about"
end
Alternatley: Menu @
About......./A&Mac197; go "about" :If the ligo is one line then it can be written in the menu itself. In Director 4.04 the backslash has been superceed by the |{shift\}
( parenthasies diable the menu e.g. greys it out so;
( cut | x | does nothing
( copy | c | does nothing. ( - parenthasies and a hypen gives you a gery rule.
Bold <B makes this word bold <igives italic, <u gives underlined, <o gives outllined, <s gives shadow.
==============================
Moveable and intersects of sprites
puppetsprite (n), true
set the moveablesprite of sprite n = true : allows the user can drag items around the stage
if sprite n intersects n then
if sprite n within n then
Exsample of this; ideal for use in a shot'em up!
 On startmovie
  puppetsprite (3), true
  puppetsprite (4), true
  set the moveablesprite of sprite 3 = true
 end
 on exitframe
  go the frame
  if sprite 3 within 2 then
   set the stagecolor = 2
  else
   if sprite 3 intersects 2 then
   set the stagecolor =22
  else
   set the stagecolor = 0
  end if
 end if
 end if
 end
 on mouseup
   set the locv of sprite 3 = the locv of sprite 3 -1
  updatestage
 end
 on idle
  set the lovh of sprite 4 = the loch of sprite 4 + 1
  updatestage
 end
=============================
File I/O:
General note's about X objects; Xobjects allow you to do a number of things that would not usually be possible using Director alone. these include launching external equipment such as video recorders,C.D. players. The most common uses are for hiding the finder on the desk top, saving files from a game to a particular location. there are six things File I/O can do:- 1)save the file to disk 2)save the file to disk giving the user a choice 3)Append data to an exsisting file 4)open a file on the disk 5)read the file on the disk 6) hide finder.IMPORTANT note that for any Xobject to work it must be stored in the same folder/file as the movie or projector calling it! With this in mind you can use the message window to access all Xobjects. Type in the message window; Show xlib; will show all the currently avialable Xobjects. Open Xlib; will open an external Xobject, if no pathname is mentioned then the Xobject must be in the same folder. Close Xlib - always always close the the xobject after use. Xobject(mdescribe) - will issue tons of junk about the object in the message window.{ all mobjects are bracketed}

How Xobjects work;

     put file IO   (mNew)   into myfile
       |              |          |
      |           |     |
     the blue print       |     the factory
              |
          the factory order
--------------------------------------------
set thestring = "hello world"
set mystring ="hello world" } this section writes
put File IO (mNew, "?write," "Untitled")
into myfile
------------------------
if objectP (myfile) then
myfile (mWritestring,mystring) }this section opens file to store
myfile (mDispose)
end if
end
------------------------
put fileIO (mNew, "?reas","TEXT") into myfile (file type has to be 4 chars ideally
if objectP (myfiel) then they must be caps)
putmyfile (mReadfile) into mytext }gives a choice of a cancel
myfile (mDispose)
end if
end
==================================
 on savefileAsk
  set theString = "Hello World"
  put fileIO(mNew,"?write","Untitled") into myFile
  if (objectP(myFile)) then
   myFile (mWriteString,theString)
   myFile(mDispose)
  end if
 end

 on savefileNoAsk
  set theString = "Hello World"
  put fileIO(mNew,"write",the pathname & "Secret") into myFile
  -- this wants file name not type
  if (objectP(myFile)) then
   myFile (mWriteString,theString)
   myFile(mDispose)
  end if
 end

 on openfileAsk
  put fileIO(mNew,"?read","TEXT") into myFile
  -- this wants the file type
  if objectP(myFile) then
   -- strip the header off
   put myFile(mReadLine) into headerStr
   if (headerStr = "MECH SIM File"&RETURN) then
    -- Handlers here
    myFile(mDispose)
  else
   alert("Sorry This is not a MECH file")
  end if
 end if
 end

 on openfileNoAsk
   put fileIO(mNew,"read",the pathname & "Secret") into myFile
  -- this needs the file name not type
  if objectP(myFile) then
  -- strip the header off
   put myFile(mReadLine) into headerStr
   if (headerStr = "MECH SIM File"&RETURN) then
   -- Handlers here
    myFile(mDispose)
   else
    alert("Sorry This is not a MECH file")
   end if
  end if
 end

 fileIO(mdescribe)
 -- Factory: FileIO ID:1020
 --=METHODS=--

ISS mNew, mode, fileNameOrType
--Creates a new instance of the XObject.
-- Mode can be :
-- "read" - Read "fileName"
-- "?read" - Select and Read "fileType"
-- "write" - Write "fileName"
-- "?write" - Select and Write "fileName"
-- "append" - Append "fileName"
-- "?append" - Select and Append "filetype"
-- FileType for ?read can be :
-- "TEXT" - standard file type
-- "trak" - cd track type
-- etc... - Any four character combination.
--
X mDispose --Disposes of XObject instance.
S mName --Returns the name of the XObject.
II mWriteChar, charNum --Writes a single character. Returns error code.
IS mWriteString, string --Writes out a string of chars. Returns error code.
I mReadChar --Returns a single character.
S mReadWord --Returns the next word of an input file.
S mReadLine --Returns the next line of an input file.
S mReadFile --Returns the remainder of the file.
--
SSS mReadToken, breakString, skipString
-- --breakstring designates character (or token) that signals to stop reading.
-- --skipstring designates what characters (or tokens) not to read.
I mGetPosition --Returns the file position.
II mSetPosition, newPos --Sets the file position. Returns error code.
I mGetLength --Returns the number of chars in the file.
ISS mSetFinderInfo, typeString, creatorString --Sets the finder info. Returns error code.
S mGetFinderInfo --Gets the finder info.
S mFileName --Returns the name of the file.
I mDelete --Delete the file and dispose of me.
I mStatus --Returns result code of the last file io activity
--
SI +mError, errorCode --Returns error message string.
-- Possible error codes:
-- -33 :: File directory full
-- -34 :: Volume full
-- -35 :: Volume not found
-- -36 :: I/O Error
-- -37 :: Bad file name
-- -38 :: File not open
-- -42 :: Too many files open
-- -43 :: File not found
-- -56 :: No such drive
-- -65 :: No disk in drive
-- -120 :: Directory not found
V mReadPICT
Next page