Just an idea for others.
I am now working different with global variables.
With this methode it is easy to find out what the global vars are and what data they contain.
Also I only have to carry away one global variable in each script instead of multiple.
So what did I do?
Wel it is easy. I define all my global variables in one Array variable called gApplicationnameV01
like here :
Code: Select all
 put gDatabaseID into gApplicationnameV01["gDatabaseID"]
With the routine below  I am always able to to see what global vars have been declared and what data they contain.
Also if I have two versions of the same application I can easy replace the gApplicationnameV01 for gApplicationnameV02 with search and replace and run them side by side without global variables getting in the way.
Also running two applications is not a problem anymore due to the different global variable array names (the application-name is therefor part of the global array variable name).
Code: Select all
// This code comes from a button, the function is an existing script from livecode tutorials. it could be simplified for this purpose.
global gApplicationnameV01
on mouseUp
  answer displayArrayData (gApplicationnameV01)
end mouseUp
 
 function displayArrayData pArray, pIndent
    # create the variable that loops through the keys in the array
    local tKey
    if pArray is an array then
        # print information to indicate that we are entering a new nested level of the array
        get "Array" & return
        # print full stops that allow the reader to track the depth of an element
        put "." after pIndent
        # create the indentation
        put tab after pIndent
        repeat for each key tKey in pArray
            # call displayArrayData with a nested array
            put format("%s[%s] => %s\n", pIndent, tKey, displayArrayData (pArray[tKey], pIndent)) after it
        end repeat
        delete the last char of it
        return it
    else
        return pArray
    end if 
end displayArrayData
If this seem interesting for you just try it and if there are big drawbacks please let me know here!
Kind regards,
Paul