karen steely <[EMAIL PROTECTED]> wrote:

> I've written a function that iterates thru a list and
> I want to manage the list remotely.
> 
> The Lingo Dictionary doesn't tell me how to read an
> external file and insert it into the code _here_.

Hi Karen,

Here's one solution, for you to adapt to your own purposes:

1.  Create a new movie
2.  Create a button sprite on the stage, with the text
    "Import snippet"
3.  Set the button cast member script to:

on mouseUp
  tFileIO   = xtra("FileIO").new()
  tFileName = tFileIO.displayOpen()
  case tFileName of
    "", VOID: exit
  end case
  
  tFileIO.openFile(tFileName, 1) -- read only
  tContents = tFileIO.readFile()
  tFileIO.closeFile()
  
  if stringP(tContents) then
    tScriptText = member("Test snippet").scriptText
    put RETURN&tContents after tScriptText
    member("Test snippet").scriptText = tScriptText
  end if
end

4.  Create an external cast
5.  Create a new button sprite on the stage with the text
    "Test snippet" and ensure that the button member is in
    the external cast*
6.  Name the button member "Test snippet"
7.  Set the button cast member script to:

on mouseUp
  doSnippet()
end

8.  Create a Movie Script with the handler:

on doSnippet()
  alert "Can't doSnippet"
end

9.  Add a "go the frame" frame script to your movie and save it
--
10. Make a projector out of your movie and save it in the same
    folder as your external cast
11. Create a folder named "Xtras" alongside the projector
12. Copy the FileIO xtra into it
--
13. Create a text file on your hard disk and name it "Snippet.txt"
14. Type the following into the text file:

on doSnippet
  alert "Doing snippet"
end

15. Launch the projector
16. Click on the "Test snippet" button:
    you'll see a "Can't doSnippet" alert
17. Click on the first button and use the FileIO dialog to
    navigate to your "Snippet.txt"
18. Click on the "Test snippet" button:
    you'll see that the alert has changed to "Doing snippet"

*You need to work with an unprotected external cast: scripts in a protected
cast have no scriptText property, so you cannot alter the scriptText of a
protected script on the fly.

Cheers,

James

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to