How can I keep a script from running if user isn't viewing records in FORM VIEW? - filemaker

In Filemaker Pro 11, I've written a script that is script triggered to run on every instance of OnRecordLoad, however I don't want it to run when user is working in LIST or TABLE VIEWS.
Is there some code I can put at the beginning of my script that does something along the lines of this logic:
"If CURRENT VIEW does not = FORM VIEW then end script"
which would effectively end the script before it ran.
I'm new at working with FM and I can't figure out a way to check the current view status within a script. If that's not possible, is there a way to limit certain script triggers are enabled depending on which view (Form, List, or Table) the user is currently in?
Thanks for any help you can provide!

Use the Get(LayoutViewState) function (http://www.filemaker.com/12help/html/func_ref2.32.50.html)
If[ Get ( LayoutViewState ) = 0 ]
//They're in form view, do stuff
Else
//They're in list view or table view, skip
End If

You script should include the following lines right at the beginning:
If[Get(LayoutViewState)<>0]{
Exit Script[]
}
That basically ensures that the script will only run when the user's layout is in Form View.
Get(LayoutViewState) returns:
0 for form view,
1 for list mode
2 for Table view.
A similar function is Get(WindowMode) that returns:
0 for Browse mode
1 for Find mode
2 for Preview mode
Hope this helps.

Related

Link editable field to a certain cell in table figure in MATLAB app designer

I am building an application in MATLAB app designer (2019b), and I am trying to link two blank fields to a table that has only two columns, such that the first field should show the first value (in the first column) in the table and the other should show the last value in the first column in the table.
Example
table:
9 2
3 4
5 6
blank field_1: 9
blank field_2: 5
I am a C++ person, so whenever I am developing, for instance in SFML, I just have one event loop that captures and updates everything - no matter where I press on the window, but, in MATLAB, whenever I press a button - I need to build a separate callback function. Here, I am not calling back anything - I just need to update the value.
Anyone, please help?
Thank you
Here's an example which illustrates how you can achieve the behavior you want.
In the below example, I am creating a uitable in the App startup, and I am defining a callback which updates the table as required when the cells are modified.
function startupFcn(app)
vars = {9,2;3,4;5,6;'blank _field_1:', '';'blank field_2:', ''};
t = uitable(app.UIFigure,'Data',vars);
t.ColumnEditable = true;
t.DisplayDataChangedFcn = #updateTable;
function updateTable(src,~)
src.Data(end-1:end,2:end) = [src.Data(1,1) src.Data(end-2,1)].';
end
end

LibreOffice BASIC function - Copy if over a value to a new sheet

I'm trying to create a simple function on a LibreOffice Calc sheet.
I have a table of information where cells A1:K2 has headings (the cells in Row 2 are merged)
all the information runs from A3:K176
The sheet has various functions running on it already, all I need is one more function.
At first I wanted it to automate when i open, but then i thought running the BASIC macro off of a button might be better, so i can edit and then just hit the button once I'm done.
I have the button linked up to run the macro already, but now im stuck... I have tried many ways of writing the code, but it seems that i am just too green to figure it out.
the last time i ran Excel advanced functions i was in high school.
ok, enough talking...
All I need the macro to do is once I hit the button, I need it to check column K and any value > 1 it needs to take that whole row and copy it then go to a target sheet, clear any data on the target sheet. then copy that set of rows to the next open row in the target sheet. possibly even exporting the result to a .txt file as a bonus.
this is a start...
in future I would like to add another button that will do the same function to a array lower down and put that into a different sheet.
Option Compatible
Sub SWD_AwakeningsTrade
Dim i, LastRow
LastRow = Sheets("Card_List").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Awakenings For trade").range("A2:I500").clearContents
For i=2 to LastRow
If Sheets("Card_List").Cells(i,"K").Value = "(>1)" Then
Sheets("Card_List").Cells(i, "K").EntireRow.Copy
Destination:=Sheets("Awakenings For trade").Range("A" & Rows.Count.end(xlUp)
End if
next i
End Sub

powerpoint run macro every time presentation hits first slide

I am have a macro running in my powerpoint presentation (2007) to update all of the linked excel data. The macro works perfectly if I run it manually but I am trying to set it to run automatically every time the presentation gets back to the first slide.
I put the following code together after looking through a few similar questions here but it doesn't seem to work. Nothing happens when I hit slide 1.
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = 1 Then
Dim osld As Slide
Dim oshp As Shape
On Error Resume Next
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
oshp.LinkFormat.update
Next oshp
Next osld
End If
End Sub
anyone have any ideas?
Your code seems correct and should work, but PowerPoint sometimes doesn't properly implement OnSlideShowPageChange.
Adding an ActiveX control to the slide (even off-slide) usually solves the problem.

Powershell Form autorun every minute

I can create a Powershell form with buttons etc that do stuff including reading a database upon a user click eg
$button1.add_click({
$label1.Text = "Checking"
$url_handle = [System.Net.WebRequest]::Create($url_to_poll)
#more stuff here
})
What I wish to create is a form that is loaded and starts polling the database automatically (eg without a user clicking a button) and repeat every minute. There will be buttons on the form that do other stuff but it's the bit above I cannot seem to work out?
you can use a timer and use the tick event. See:
https://msdn.microsoft.com/en-us/library/system.windows.forms.timer(v=vs.110).aspx

How can I show a specific record near the top in list view without screen flicker?

I have a script (in FileMaker 14) that sets a variable, $_record_number, to Get ( RecordNumber ) based on a specific criterion. Once it's been set, I want to bring that record to the top in list view. (It's possible that the criterion is never fulfilled and that $_record_number is empty.)
The portion of the script that does this looks like the following:
Go to Record/Request/Page [ Last ]
Refresh Window []
Go to Record/Request/Page [ No dialog ; Max ( $_record_number ; 1 ) ]
When the Refresh Window step isn't present, the script doesn't work correctly. Instead of bringing the record to the top of the list view, it brings it to the bottom.
Unfortunately, the Refresh Window step causes the window to flicker as the script redraws the layout.
Is there a way to duplicate the end results of the above steps without using Refresh Window and avoid the screen redraw?
Failed techniques I've tried:
Using Refresh Object instead of Refresh Window targeting objects in both the header and body
Using Go to Related Record with a relationship to the target record
If you're using FileMaker 13 or higher, you can try the Refresh Object script step instead of Refresh Window. See http://www.filemaker.com/help/13/fmp/en/html/scripts_ref2.37.62.html for more details on that specific step.
I've sometimes had issues refreshing portals without Refresh Window, but if you just need the text on a label or button to update when the variable does, it should work fine.
Chuck, one straightforward option would be to add an unstored calc field to your portal table, with a calc of Get(RecordNumber) = $_record_number. You could set the sort of your portal to reverse sort on this calc field. Since only the matching field should match, this should always pop the desired record (if any) to the top, and otherwise, this condition would be ignored.
Another option would be to manually step through your portal in a Loop and stop when you find a match.
Last, I'd wonder if it might be cleaner to store and test against your portal table's primary key instead of its record number, but that's of course beyond the scope of this question. Good luck :-)
I am in FM14, and I think this works: get rid of your lines that go to last record and refresh window and instead insert 'Scroll Window [ End ]', e.g.
Scroll Window [ End ]
Go to Record/Request/Page [ No dialog ; $recordNumber ]