Home‎ > ‎

Advanced Topics

1. Abbreviations
You can abbreviate words in LiveCode, usually by leaving out the vowels. 

    You can abbreviate:
             "button" with "btn"
                 "card" with "crd"
                 "graphics" with "grc"
                 "cr" for "carriage return", and others. 

    If you are not sure of an abbreviation, try it - if it is wrong it will let you know (in color)

2. Grouping Objects
If you have a lot of objects (like buttons, "rocks" , etc), you can group them together and use the same code for all of them. that way, you only write the code once. For instance, if you have a submarine going through a mine field, instead of having to write an "intersect" command for each of them, you can group them and write one intersect command for all of them.

    Instead of...
            If intersect (button "sub", button "mine1", 255 ) then
                    answer "Boom"
            end if
            If intersect (button "sub", button "mine2", 255 ) then
                    answer "Boom"
            end if
            If intersect (button "sub", button "mine3", 255 ) then
                    answer "Boom"
            end if
                etc.....


    You would have:
            If intersect (button "sub", group "mines", 255 ) then
                    answer "Boom"
            end if

You group them by holding your mouse down and selecting all of them. Then click on the "Group" icon on the top "Edit bar" in LiveCode. Name it and     you are done


3. Variations of the Ask command
The Ask command has many variations for you to use to automate common tasks. Please see the dictionary for more on these.
    
    a. "Ask file" to let the user specify the name and location for a new file

        e.g.
                   ask file "Please name the file:"

         ask file "Save data as" 

         ask file "Export picture as:" with filter "JPEG file,*.jpg"


4. Variations of the Answer command
The Answer command has many variations for you to use to automate common tasks. Please see the dictionary for more on these.
    

    a.  "Answer folder" gives a file dialog for the user to choose a folder 


            e.g.       answer folder "Please choose a folder:"


    b.  "Answer file" gives a dialog for the user to choose a file 


            e.g.      answer file "Select a file to delete:"
                        answer file "Select a file to read:"


    c.  "Answer color" gives a dialog for the user to choose a color 


            e.g.      answer color
                        answer color with "red"


    d.  "Answer printer" gives a dialog for the user to select a printer 


            e.g.     answer printer

Comments