MBS_TriggerScript | theScriptName;theFileName | All accounts | /*###############################################
MBS_TriggerScript
created 10/26/06, by Todd Geist, todd@geistinteractive.com
Parameters: theScriptName, theFileName
Dependancies: MBS FileMaker Plug-in.
Notes: Uses VBScript and Applescript to run a script
################################################*/
Let(
[
Applescript = "do script " & Quote(theScriptName);
VBScriptText =
"FUNCTION DoFMSCript(FileName, ScriptName)" & "¶" &
"Set fmApp = CreateObject(\"FMPro.Application\")" & "¶" &
"fmApp.Visible = True" & "¶" &
"Set fmDocs = fmApp.Documents" & "¶" &
"For Each fmDoc In fmDocs" & "¶" &
"If InStr(LCase(fmDoc.fullname), LCase(FileName)) > 0 Then" & "¶" &
" fmDoc.dofmscript (ScriptName)" & "¶" &
"End If" & "¶" &
"Next" & "¶" &
"END FUNCTION";
ScriptID = MBS("WindowsScript.Create");
lang= MBS("WindowsScript.SetLanguage"; ScriptID; "VBScript");
addcode = MBS("WindowsScript.AddCode"; ScriptID; VBScriptText)
];
Case(
Get ( SystemPlatform ) = 1;
// Mac OSX Case
MBS(
"Applescript.Run";
Applescript
);
// Windows Case
MBS("WindowsScript.ExecuteFunction";ScriptID; "DoFMScript";theFileName; theScriptName) &
MBS("WindowsScript.Close"; ScriptID)
)
) |
| |
gi_zpvt | | All accounts | |
| |
gi_zpvt_ P R I V A T E gi F R A M E W O R K F U N C T I O N S | | All accounts | |
| |
gi_zpvt_mls_GetLayoutsInGroupHelper | theList;theFilter;theLayout;level | All accounts | /*############################################################################################
PURPOSE:
Parses the layout list that is passed to it to return only the layouts that are in the same layout Level Group
HISTORY
Modified 1/4/06. Todd Geist
Created 12/25/05, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Recursive function
############################################################################################*/
Let(
[
// return the layout if it is a sibling based on theFilter
firstLine = GetValue( theList; 1 );
isMatch = (theFilter = Left(firstLine; Length(theFilter)));
result = If(isMatch; firstLine & "¶"; "");
// shorten the list
remaining = RightValues(theList; ValueCount(theList) - 1);
// destroy any sibling duplicates which would come from sub tabs
e = Position(firstLine; "/"; 1; level +1);
remaining2 =
Case(
isMatch;
Substitute(
"*^~¶" & remaining;
[ "¶" & Left(firstLine; e ); "¶@%"];
["*^~¶"; ""];
["*^~"; ""]
);
remaining
)
];
Case(
ValueCount(theList)>=1;
result & gi_zpvt_mls_GetLayoutsInGroupHelper(remaining2; theFilter; theLayout; level);
""
)
) |
| |
gi_zpvt_mls_GetLayoutsInNavSet | | All accounts |
/*#####################################################################################
PURPOSE:
Returns the list of lkayouts in the Nav Set
HISTORY
Created 1/25/06. Todd Geist
PARAMTERS:
theList
NOTES:
only returns layouts that has 2 "/" in the name
uses a recursive helper function
this function is called many time as a layout draws. The first time a new layout is drawn the result is stored in Variable.
After that the function simple retrives the variable instead of calling the recursive function. Caching
######################################################################################*/
Let(
[
theList = LayoutNames ( Get ( FileName ) );
$$fw.LayoutNames =
Case(
$$fw.Lastlayout = Get ( LayoutName ); $$fw.LayoutNames;
gi_zpvt_mls_GetLayoutsInNavSetHelper ( theList )
);
$$fw.lastLayout = Get ( LayoutName )
];
$$fw.LayoutNames
) |
| |
gi_zpvt_mls_GetLayoutsInNavSetHelper | theList | All accounts | /*#####################################################################################
PURPOSE:
Recursive helper function
HISTORY
Modified 1/25/06. Todd Geist Created 12/25/05, Todd Geist
PARAMTERS:
theList
NOTES:
Recursive function
######################################################################################*/
Let(
[
// find only the layouts that have two "/"
firstLine = GetValue( theList; 1 );
isMatch = GetAsBoolean(Position(firstLine; "/"; 1; 2));
result = If(isMatch; firstLine & "¶"; "");
// shorten the list
remaining = RightValues(theList; ValueCount(theList) - 1)
];
Case(
ValueCount(theList)>=1;
result & gi_zpvt_mls_GetLayoutsInNavSetHelper(remaining);
""
)
) |
| |
gi_mls_GetLayoutGroupLabels | level | All accounts |
/*############################################################################################
PURPOSE:
Retuns the Labels for all the layouts that are in the current layouts group.
HISTORY
Created 12/25/05, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Often used for the Tab Lables on Tabbed Interfaces, but is more general.
############################################################################################*/
Let(
[
n = Get ( CalculationRepetitionNumber );
siblingLayouts = gi_mls_GetLayoutsInGroup ( level );
thisRepeatsLayout = GetValue( siblingLayouts ; n );
s = Position(thisRepeatsLayout; "/";1 ;level) + 1;
e = Position(thisRepeatsLayout; "/";1 ;level + 1);
size = e - s
];
Middle(thisRepeatsLayout; s; size)
) |
| |
gi_mls_GetLayoutsInGroup | level | All accounts | /*###############################################################################
PURPOSE:
Retuns a list of the First Layouts at this level.
HISTORY
Created 12/25/05, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Often used for the Tab Lables on Tabbed Interfaces, but is more general.
FIRST Layouts refers to the fact that I don't need every layout in group. I just need one.
############################################################################################*/
Let(
[
thisLayout = Get ( LayoutName );
e = Position(thisLayout; "/"; 1; level)
];
gi_zpvt_mls_GetLayoutsInGroupHelper (
gi_zpvt_mls_GetLayoutsInNavSet;
Left(thisLayout; e) ;
thisLayout ;
level
)
) |
|
|
gi_mls_GroupNavigationBar | level;graphic;selectedGraphic | All accounts | /*################################################################################
PURPOSE:
Displays the graphics for a Navigation Bar
HISTORY:
Created 1/29/06, Todd Geist
Created 1/7/06, Todd Geist
PARAMETERS:
level - the group level for the graphic
graphic - the background for the Navigation Bar
selectedGraphic - the background graphic when the item is Hilited
NOTES:
Part of the MLS navigation system
################################################################################*/
Let(
[
r = Get ( CalculationRepetitionNumber );
thisRepeatsLayout = GetValue(gi_mls_GetLayoutsInGroup ( level ); r);
groupMatch = gi_mls_ButtonState ( level )
];
// n will be either 1 or 2. 2 is deselected
Case(
IsEmpty(thisRepeatsLayout); "";
GroupMatch; selectedGraphic;
graphic
)
) |
| |
gi_mls_GetLayoutGroupLabelsBold | level | All accounts | /*############################################################################################
PURPOSE:
Retuns the Labels for all the layouts that are in the current layouts group.
HISTORY
Created 12/25/05, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Often used for the Tab Lables on Tabbed Interfaces, but is more general.
############################################################################################*/
Let(
[
n = Get ( CalculationRepetitionNumber );
siblingLayouts = gi_mls_GetLayoutsInGroup ( level );
thisRepeatsLayout = GetValue( siblingLayouts ; n );
thisRepeatsGroup = Left(thisRepeatsLayout; Position(thisRepeatsLayout; "/";1; level +1));
thisLayoutsGroup = Left(Get ( LayoutName ); Position(Get ( LayoutName ); "/";1; level +1));
groupMatch = (thisRepeatsGroup = thisLayoutsGroup) ;
s = Position(thisRepeatsLayout; "/";1 ;level) + 1;
e = Position(thisRepeatsLayout; "/";1 ;level + 1);
size = e - s;
label = Middle(thisRepeatsLayout; s; size)
];
Case(
groupMatch; TextColor(TextStyleAdd(label; Bold);RGB(0;0;0));
label
)
) |
| |
gi_GetAs_pListAsVariables | pList;type | All accounts | /*############################################################
PUPOSE:
converts a pList to either LOCAL or GLOBAL variables
VERSION;
1.0.1
HISTORY:
Modified 1/2/06, Todd Geistr
Created 11/26/05, Todd Geist
PARAMETERS:
pList - this is the pList to convert
type - either $$ for "Global" or $ for "Script". "$" is the defualt
NOTES:
a pList is name value pair list. Usually in the form of
name1 = Value1
name2 = Value2
etc.
##############################################################*/
Let(
[
quotedpList = gi_zpvt_ConvertpListToVariablesHelper ( pList );
varPrefix = Case(type = "$$"; "$$"; "$");
pList = varPrefix &
Substitute(
quotedpList & "x";
["¶x"; ""];
["¶"; ";¶" & varPrefix]
);
evalText = "Let(¶[¶" & pList & "¶];¶\"\"¶)"
];
//evalText
Evaluate(evalText)
) |
|
|
gi_pList_Item | propertyName;propertyValue | All accounts | /*######################################################################################################
PURPOSE:
Packages the propertyName, propertyValue as a pList Item.
HISTORY:
Modified 1/2/06, Todd Geist
Creadted 10/2/05, Todd Geist
NOTES:
example: Passing "Name" and "Value" tot he function results in
name= Value
######################################################################################################*/
Let(
[
fieldDel = "=";
recordDel = "¶";
needsQuote= Position(propertyValue; fieldDel; 1; 1) or Position(propertyValue; recordDel; 1; 1) or IsEmpty(propertyValue);
valueQuoted =
Case(
needsQuote; "~" &Quote(propertyValue);
" " & propertyValue
)
];
propertyName & "=" & valueQuoted & "¶"
) |
| |
gi_zpvt_ConvertpListToVariablesHelper | pList | All accounts | /*############################################################################
PURPOSE:
Recusive Helper function. Only used by the "Var_ConvertpListToVariables"
HISTORY:
Created, Todd Geist, 12/1/05
NOTES:
############################################################################*/
Let(
[
vCount = ValueCount(pList);
thisItem = GetValue( pList ; 1 );
sepPos = Position(thisItem; "="; 1;1);
thisName = Left(thisItem; sepPos - 1);
thisValue = Middle(thisItem; sepPos + 2; 10000);
alreadyQuoted = Position(thisItem; "~"; 1; 1) > 0 or (thisValue = GetAsNumber(thisValue));
convertedItem = thisName & "= " & Case(not AlreadyQuoted; Quote(thisValue); thisValue);
remainingPList = RightValues(pList; vCount-1)
];
convertedItem & "¶" &
Case(
vCount > 1; gi_zpvt_ConvertpListToVariablesHelper(remainingPList);
""
)
) |
| |
gi_Strings_VarEncode | string | All accounts | /*########################################################################################
PURPOSE:
Encodes a string so it is safe for use as a Variable Name
HISTORY:
Created 1/2/06, Todd Geist
NOTES:
Work in progress. Not addressing " and " and other word operators
########################################################################################*/
Let(
[
char = "%"
];
Substitute(
string;
["+"; char & "01"];
["-"; char & "02"];
["*"; char & "03"];
["/"; char & "04"];
["^"; char & "05"];
["&"; char & "06"];
["≠"; char & "07"];
["<>"; char & "08"];
["<"; char & "09"];
[">"; char & 10];
["≥"; char & 11];
["≤"; char & 12];
["("; char & 13];
[")"; char & 14];
[","; char & 15];
[";"; char & 16];
["]"; char & 17];
["["; char & 18];
["\""; char & 19];
["::"; char & 20];
["$"; char & 21];
["}"; char & 22]
)
) |
|
|
gi_DeclareVariable | name;value | All accounts | /*############################################################
PUPOSE:
Sets a global and adds it's name to a list stored in another global
VERSION;
1.0.1
HISTORY:
Created 11/28/05, Todd Geist
PARAMETERS:
name - the Name of the Variable
value = the value of the global
NOTES:
Use instead of setting globals directly
Useful for keeping track of globals that are in use
##############################################################*/
Let (
[
// check the name for $$
var = Case (PatternCount ( name ; "$" ) = 0 ; "$$" & name ; name ) ;
// log if it is the first use
fistUse = not (Position( "$$" & $$GlobalVariableList & "¶"; var & "¶";1; 1));
$$GlobalVariableList =
Case(
fistUse; $$GlobalVariableList & var & "¶";
$$GlobalVariableList
);
// actually set the value
letTxt = "Let ( " & var & " = \"" & value & "\";1 )" ;
result = Evaluate ( LetTxt )
] ;
result
) |
|
|
gi_mls_ButtonState | level | All accounts | /*############################################################################################
PURPOSE:
Returns the state of the current button of a Navigation Bar
HISTORY
Created 10/27/06, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Often used for the Tab Lables on Tabbed Interfaces, but is more general.
############################################################################################*/
Let(
[
n = Get ( CalculationRepetitionNumber );
siblingLayouts = gi_mls_GetLayoutsInGroup ( level );
thisRepeatsLayout = GetValue( siblingLayouts ; n );
thisRepeatsGroup = Left(thisRepeatsLayout; Position(thisRepeatsLayout; "/";1; level +1));
thisLayoutsGroup = Left(Get ( LayoutName ); Position(Get ( LayoutName ); "/";1; level +1));
groupMatch = (thisRepeatsGroup = thisLayoutsGroup)
];
groupMatch
) |
| |
gi_mls_ButtonPosition | level | All accounts | /*############################################################################################
PURPOSE:
Returns the state of the current button of a Navigation Bar
HISTORY
Created 10/27/06, Todd Geist
PARAMTERS:
Level - the group level. A layout can belong to several level of groups.
NOTES:
Often used for the Tab Lables on Tabbed Interfaces, but is more general.
############################################################################################*/
Let(
[
n = Get ( CalculationRepetitionNumber );
siblingLayouts = gi_mls_GetLayoutsInGroup ( level );
thisRepeatsLayout = GetValue( siblingLayouts ; n );
lastLayout = Substitute(RightValues(siblingLayouts; 1); "¶"; "")
];
Case(
n = 1 and thisRepeatsLayout = lastLayout; "Only";
n = 1; "First";
thisRepeatsLayout = lastLayout; "Last";
not IsEmpty(thisRepeatsLayout) ; "Middle";
""
)
) |
| |