TITLE
    HyperCard:Problem Pasting Fields-Bad Script (3/94)
Article ID:
Created:
Modified:
14972
3/22/94
3/22/94

TOPIC


    I am trying to paste the card number field from "Display the card number" from Readymade Fields Stack into the Addresses stack in HyperCard 2.2, but it's not working. It pastes fine into a new blank field. Both stacks come on the standard HyperCard distribution disks.


DISCUSSION


    The problem is with the script in the stack that came with HyperCard.

    Below is a portion of the original script.

    on addStackScript fieldType
    get script of fieldType
    if "openCard" is in it then
    if (fieldType && "field id" && id of me) is not in it then
    put scriptBody(fieldType) & return after char ┬
    (offSet("openCard",it) + 8) of it
    set script of fieldType to it
    end if
    else
    if it ¡ empty then
    if last char of it = return then put return after it
    else put return & return after it
    end if
    -- write the full handler
    put "on openCard" & return & scriptBody(fieldType) & return & ┬
    "pass openCard" & return & "end openCard" after it
    set script of fieldType to it
    end if
    end addStackScript

    The first "if" statement (if "openCard" is in it then) should really test for "on openCard" instead of "openCard". Many stacks list handlers included in a script at the top of the script. This allows programmers to easily search a script for a particular handler. The addresses stack does this. When this button is pasted into it, the "openCard" in the handler list makes the conditional true and the script to include the card number is pasted into the handler list (where it will never execute).

    Change"openCard" to "on openCard" in two places (as below in line 3 and 6) and the script works as advertised.

    on addStackScript fieldType
    get script of fieldType
    if "on openCard" is in it then
    if (fieldType && "field id" && id of me) is not in it then
    put scriptBody(fieldType) & return after char ┬
    (offSet("on openCard",it) + 8) of it
    set script of fieldType to it
    end if
    else
    if it ¡ empty then
    if last char of it = return then put return after it
    else put return & return after it
    end if
    -- write the full handler
    put "on openCard" & return & scriptBody(fieldType) & return & ┬
    "pass openCard" & return & "end openCard" after it
    set script of fieldType to it
    end if
    end addStackScript

    Support Information Services

Document Information
Product Area: Apple Software
Category: HyperCard
Sub Category: About HyperCard

Copyright © 2000 Apple Computer, Inc. All rights reserved.