Permalink
Browse files

adding functions from fmfunctions repo

  • Loading branch information...
1 parent 1f466d8 commit 5ccef9428109780c91b088ee806fc57959e553e8 @petrowsky petrowsky committed Oct 13, 2010
Showing with 197 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +57 −0 Functions/Debug.fmfn
  3. +33 −0 Functions/Developer.fmfn
  4. +68 −0 Functions/ErrorReference.fmfn
  5. +38 −0 Functions/WindowCenter.fmfn
View
@@ -1 +1,2 @@
*.fp7
+Import.log
View
@@ -0,0 +1,57 @@
+/**
+ * =====================================================
+ * Debug ( )
+ *
+ * PARAMETERS:
+ * none
+ * RETURNS:
+ * (string) A list of informative values
+ * about the current FMP environment.
+ * DEPENDENCIES:
+ * Developer ()
+ * NOTES:
+ *
+ * RELEASE: 101009
+ * =====================================================
+ *
+ */
+
+If ( Developer;
+ Let ( [
+ // Variables
+ $$DEBUG = List (
+ "App Version = " & Abs ( Get ( ApplicationVersion ) );
+ "App Current Time = " & GetAsText ( Get ( CurrentTimeStamp ) );
+ "Host Name = " & Get ( HostName );
+ "Host IP = " & Get ( HostIPAddress );
+ "File Location = " & Get ( FilePath );
+ "Account = " & Get ( AccountName );
+ "-----------------------------------";
+ "Script Param = " & Get ( ScriptParameter );
+ "Script Result = " & Get ( ScriptResult );
+ "-----------------------------------";
+ "Last Error = " & Get ( LastError );
+ "Last ODBC = " & Get ( LastODBCError );
+ "-----------------------------------";
+ "Layout = " & Get ( LayoutName );
+ "Layout Table = " & Get ( LayoutTableName );
+ "-----------------------------------";
+ "Open Records = " & Get ( RecordOpenCount );
+ "Record Modified = " & Get ( RecordModificationCount );
+ "-----------------------------------";
+ "Active Field = " & Get ( ActiveFieldName );
+ "Active Field Table = " & Get ( ActiveFieldTableName );
+ "Active Layout Object = " & Get ( ActiveLayoutObjectName );
+ "Active Layout Table = " & Get ( LayoutTableName );
+ "-----------------------------------";
+ "Local time = " & Get ( CurrentTimeStamp );
+ "Host time = " & Get ( CurrentHostTimeStamp );
+ "-----------------------------------";
+ )
+ ];
+
+ // Return value
+ $$DEBUG
+
+ )
+)
View
@@ -0,0 +1,33 @@
+/**
+ * =====================================================
+ * Developer ( )
+ *
+ * PARAMETERS:
+ * none
+ * RETURNS:
+ * (bool) True or False based on proper
+ * evaluation
+ * DEPENDENCIES:
+ * none
+ * NOTES: Because FileMaker changed Get ( PrivilegeSetName )
+ * Evaluate () must be used
+ *
+ * RELEASE: 101011
+ * =====================================================
+ *
+ */
+
+Let ( [
+
+ var.developers = List( ""; "" ) // Add the names of the accounts which are valid developer accounts
+
+];
+
+ PatternCount ( ¶& var.developers &¶ ; ¶& Get ( AccountName ) &¶ ) ≥ 1
+ or
+ If ( GetAsNumber ( Get ( ApplicationVersion ) ) < 11;
+ Evaluate ( "Get ( PrivilegeSetName )" ) = "[Full Access]";
+ Evaluate ( "Get ( AccountPrivilegeSetName )" ) = "[Full Access]"
+ )
+
+)
@@ -0,0 +1,68 @@
+/**
+ * =====================================================
+ * ErrorReference ( elementName ; requiredElementNames ; requiredType )
+ *
+ * PARAMETERS:
+ * @elementName = FileMaker field reference
+ * @requiredElementNames = List() of required element names
+ * @requiredTypes = matching list of types for each element
+ * RETURNS:
+ * (boolean) Whether or not there is a calculation error
+ * DEPENDENCIES:
+ * none
+ * NOTES:
+ * References, at time of evaluation, are based on
+ * current context.
+ * =====================================================
+ *
+ */
+
+Let ( [
+ $$ERROR.REFERENCE = ""; // always start as if there is no error
+ // Set a global variable with match values - only make function calls on first iteration
+ $$TEMP = If ( IsEmpty ( $$TEMP );
+ FilterValues (
+ Case (
+ requiredType = "Table";
+ TableNames ( Get ( FileName ) );
+
+ requiredType = "Field";
+ FieldNames ( Get ( FileName ) ; Get ( LayoutName ) );
+
+ requiredType = "Layout";
+ LayoutNames ( Get ( FileName ) );
+
+ requiredType = "Object";
+ LayoutObjectNames ( Get ( FileName ) ; Get ( LayoutName ) );
+
+ requiredType = "Window";
+ WindowNames ( Get ( FileName ) );
+
+ ""
+ ); requiredElementNames );
+ // Else
+ $$TEMP
+ );
+
+ var.topValue = GetValue ( requiredElementNames ; 1 );
+ var.valueExists = PatternCount ( $$TEMP; var.topValue ) ≥ 1 or var.topValue = "";
+ var.remaingValues = RightValues ( requiredElementNames ; ValueCount ( requiredElementNames ) - 1 )
+ // The following line is used for debugging
+ //$$ITERATIONS = List ( $$ITERATIONS ; List ( "top:¶" & Quote ( var.topValue ) ; "exists:¶" & var.valueExists ; "remains:¶" & Quote ( var.remaingValues ) ; "match:¶" & $$TEMP ; "----------------") )
+];
+ If ( not var.valueExists; // return the error
+ Let ( [
+ $$TEMP = ""; // reset the temp variable
+ $$ERROR.REFERENCE = elementName & ": Missing literal references"
+ ];
+ True
+ );
+
+ // Else
+
+ If ( var.remaingValues = "";
+ Let ( $$TEMP = "" ; False );
+ ErrorReference ( elementName ; var.remaingValues ; requiredType )
+ )
+ )
+)
@@ -0,0 +1,38 @@
+/**
+ * =====================================================
+ * WindowCenter ( dimension )
+ *
+ * PARAMETERS:
+ * @dimension (enumeration) Vertical, Horizontal
+ * RETURNS:
+ * (int) Screen position value based on dimension
+ * supplied
+ * DEPENDENCIES:
+ * none
+ * NOTES:
+ * Using a locally scoped variable within your
+ * script will alter what this function returns
+ * $parentWindowHeight for window height of parent
+ * $parentWindowWidth for window width of parent
+ * $parentWindowTop for window top of parent
+ * $parentWindowLeft for window left of parent
+ * =====================================================
+ *
+ */
+
+Let ([
+
+ var.vertical = PatternCount ( dimension ; "vert" );
+ var.horizontal = PatternCount ( dimension ; "horiz" );
+ var.parentHeight = If ( IsEmpty ( $parentWindowHeight ) ; Get ( WindowDesktopHeight ) ; $parentWindowHeight );
+ var.parentWidth = If ( IsEmpty ( $parentWindowWidth ) ; Get ( WindowDesktopWidth ) ; $parentWindowWidth )
+
+];
+
+ Case (
+ var.vertical;
+ ( var.parentHeight / 2) - ( Get ( WindowHeight ) / 2 ) + $parentWindowTop;
+ var.horizontal;
+ ( var.parentWidth / 2) - ( Get ( WindowWidth ) / 2 ) + $parentWindowLeft
+ )
+)

0 comments on commit 5ccef94

Please sign in to comment.