Newbie question

Jeanne A. E. DeVoto jeanne at
Sun Jun 23 14:01:01 EDT 2002

At 10:03 AM -0700 6/23/2002, Glen L. Bledsoe wrote:
>First question: If I create a stack in which the user creates new cards
>within that stack, will those new cards be saved?

Only if the stack file they're in is saved. (You can do this in your app
with the save command - either do it automatically or provide a Save menu

If your stack is part of a standalone application, however, you can't save
it; standalones can't be saved. (Windows and Unix OSs don't allow the
running app to save to itself, and for consistency this is also enforced on
Mac OS.)

The best approach here is to save the stack as a separate stack file, and
either open it directly (if the stacks behave as documents, say if your app
creates small databases), or read in the data on startup and place it in
the appropriate fields, etc.

>Second question: I want to create a stack in which the user can type in
>a field and change the font, size and style. I can create those menus,
>but I don't know what scripts to put in them. (I do know how to handle
>this in SuperCard, and of course HyperCard created its own menus.) There
>are examples of interesting stacks on the website, but it would be nice
>just to have a very basic example stack that handled basic menus of what
>anybody might find in a basic text editor.

You might want to take a look at the example stack in the Independent Study
tutorial - it is a small application with (heavily-commented) code you can
look at for basic tasks like this.

Also, there will be a number of scripts to handle Text menus in the
upcoming Cookbook (next version). Here's one:

on menuPick theMenuItem -- goes in the menu button
  set the itemDelimiter to "|"
  switch item 1 of theMenuItem -- the submenu name
  case "Font"
    set the textFont of field "Example Text" to item 2 of theMenuItem
  case "Size"
    set the textSize of field "Example Text" to item 2 of theMenuItem
  case "Color"
    set the textColor of field "Example Text" to item 2 of theMenuItem
  case "Plain"
    -- plain removes all styles
    set the textStyle of field "Example Text" to empty
  default -- for Bold, Italic, Underline
    put the textStyle of field "Example Text" into currentStyle
    set the itemDelimiter to comma
    if theMenuItem is among the items of currentStyle then
      -- already has that style, so remove it
      delete item (itemOffset(theMenuItem,currentStyle)) \
         of currentStyle
      -- add the style to any existing styles
      put comma & theMenuItem after currentStyle
    end if
    set the textStyle of field "Example Text" to currentStyle
  end switch
end menuPick

You might want to change "field "Example Text"" to "the selectedChunk", if
you want users to make changes to the selected text instead of entire

>Third question: In the Rinaldi plugin, revPrefsBuilder 1.2, the
>preference file is placed (on a Mac anyway) in the System Folder's
>Preference folder. How would the script need to be changed to place the
>preferences inside the folder with the application. I can see problems
>where someone is moving a stack from computer to computer and the data
>doesn't follow the stack because it's buried in the System Folder. If it
>were in the same folder as the stack, copying the folder would do the

Check out the defaultFolder property. This is the starting point for all
relative paths, and (unless you change it) it's the folder the running
application is in, so if you haven't changed the defaultFolder, the path to
a file in that folder is just the filename:
  open file "Preferences"
  put myStuff into URL "file:Preferences"

Jeanne A. E. DeVoto ~ jeanne at
Runtime Revolution Limited - The Solution for Software Development

More information about the Use-livecode mailing list