Setting Multiple Variables to the Same Value in One Line - applescript

Hey I am wondering if there is a way to collapse this bit of code, so its not 12 lines of setting variables.
Current Code:
set isVideo to false
set isTV to false
set isMovie to false
set isRawVideo to false
set isDocumentary to false
set isAudio to false
set isSports to false
set isUnknown to false
set toPrompt to false
set BTNChoice to ""
set keyword to ""
set keywordHit to ""
What I'm hoping for:
set (isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt) to false
set (BTNChoice, keyword, keywordHit) to ""
Or:
isVideo = isTV = isMovie = isRawVideo = isDocumentary = isAudio = isSports = isUnknown = toPrompt = false
BTNChoice = keyword = keywordHit = ""
Let me know if theres a way to reduce this or if I'm stuck with one variable per line.
Ryan

The only one-liner way is
set {isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt} to {false, false, false, false, false, false, false, false, false}
set {BTNChoice, keyword, keywordHit} to {"", "", ""}
Or even a real one-liner
set {isVideo, isTV, isMovie, isRawVideo, isDocumentary, isAudio, isSports, isUnknown, toPrompt, BTNChoice, keyword, keywordHit} to {false, false, false, false, false, false, false, false, false, "", "", ""}
The number of items on the right side must not be less than the number of items on the left side.

Related

Prolog query :- true, fail; not true, not fail; true, not fail

I am solving a test for an exam and I got this question with the following answers:
fail
yes
true
no
Running it in the shell i get True, but i cannot understand how this answer is obtained.
I get the first part true, fail;but the rest is a mistery.
Am i supposed to look just at the last part true, not fail?
true, fail; not true, not fail; true, not fail
Can be translated into the following logical expression:
(true and false) or (((not true) and (not false)) or (true and (not false)))
That we can simplify progressively...
(true and false) or ((false and true) or (true and true))
false or (false or true)
false or true
true

rmarkdown comments or something similar

When the rmarkdown file is knitted, there are something after the title area, as it is shown in the picture.
How to remove those?
I have set "warning=FALSE, comment=NA" in the r code chunk, but it does not work.
Some of the codes are as follows:
---
title: 'Validness Report by All Facilities'
subtitle: '2017-01-03 to 2017-01-09'
output: pdf_document
geometry: margin=0.5in
classoption: landscape
documentclass: article
---
```{r input, echo = FALSE, results = 'hide', cache = TRUE,
warning=FALSE, comment=FALSE, error=FALSE}
setwd("F:/")
dfDataIn_valid2 <- read.csv("full_valid.csv", stringsAsFactors = FALSE)
```
```{r validness, echo = FALSE, results = 'hide',
cache = TRUE, warning=FALSE, comment=FALSE, error=FALSE}
# Check if required packages are installed. If not, install them.
packages <- c("rJava", "xlsxjars", "xlsx", "lubridate", "dplyr", "lazyeval")
lapply(packages, library, character.only = TRUE)
```
You need chunk option message set to FALSE
```{r, echo = FALSE, results = 'hide', cache = TRUE, warning=FALSE, comment=FALSE, error=FALSE, message=FALSE)}
Also, you don't need to repeat the options for each chunk; you could also just set them in the first one:
```{r}
library(knitr)
opts_chunk$set(echo = FALSE, results = 'hide', cache = TRUE, warning=FALSE, comment=FALSE, error=FALSE, message=FALSE)
```

How to automate third-party UI control

I'm trying to extracting data from third-party software. The window has a customised tab control (not the standard one) which contains multi SysTreeView32 in tabs.
The software has different versions and each version has different set of tabs.
Both Inspect.exe and Spy++ only show the control itself without any information about the tab children.
Do you know how to programmatically select the specific tab by its title?
Here's the information of the 3rd-party control from Inspect.exe
How found: Mouse move (292,346)
hwnd=0x005203F6 32bit class="Afx:5080000:0:10003:0:0" style=0x56000000 ex=0x0
Name: ""
ControlType: UIA_PaneControlTypeId (0xC371)
LocalizedControlType: "窗格"
BoundingRectangle: {l:98 t:327 r:410 b:1014}
IsEnabled: true
IsOffscreen: false
IsKeyboardFocusable: true
HasKeyboardFocus: false
AccessKey: ""
ProcessId: 36076
RuntimeId: [2A.5203F6]
AutomationId: "221"
FrameworkId: "Win32"
ClassName: "Afx:5080000:0:10003:0:0"
NativeWindowHandle: 0x5203F6
ProviderDescription: "[pid:41692,hwnd:0x5203F6 Main:Nested [pid:36076,hwnd:0x5203F6 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText: ""
LegacyIAccessible.ChildId: 0
LegacyIAccessible.DefaultAction: ""
LegacyIAccessible.Description: ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: ""
LegacyIAccessible.Role: 客户端 (0xA)
LegacyIAccessible.State: 可设定焦点 (0x100000)
LegacyIAccessible.Value: ""
IsAnnotationPatternAvailable: false
IsDragPatternAvailable: false
IsDockPatternAvailable: false
IsDropTargetPatternAvailable: false
IsExpandCollapsePatternAvailable: false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable: false
IsItemContainerPatternAvailable: false
IsLegacyIAccessiblePatternAvailable: true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable: false
IsRangeValuePatternAvailable: false
IsScrollItemPatternAvailable: false
IsScrollPatternAvailable: false
IsSelectionItemPatternAvailable: false
IsSelectionPatternAvailable: false
IsSpreadsheetItemPatternAvailable: false
IsSpreadsheetPatternAvailable: false
IsStylesPatternAvailable: false
IsSynchronizedInputPatternAvailable: false
IsTableItemPatternAvailable: false
IsTablePatternAvailable: false
IsTextChildPatternAvailable: false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available: false
IsTogglePatternAvailable: false
IsTransformPatternAvailable: false
IsTransform2PatternAvailable: false
IsValuePatternAvailable: false
IsVirtualizedItemPatternAvailable: false
IsWindowPatternAvailable: false
FirstChild: "" 树
LastChild: "" 树
Next: [null]
Previous: [null]
Other Props: Object has no additional properties
Children: "" 树
Ancestors: "" 窗格
"" 窗格
"" 窗格
"V6" 对话框
"" 窗格
"" 窗格
"" 容器
"V9.32" 窗口
"桌面" 窗格
[ No Parent ]
If "AutomationId" is unique, can we try to map the logical names with the "AutomationId" & use those fields in automation. I may be wrong, but a possible solution.

Switch-Hide pictures based on cell values

I am not an expert on VBA, all I know is based on browsing internet, but some simple codes work for me well.
I am switching pictures based on P52 value, that works perfectly, but then I want to swich different pictures based on cell value P117 and that part of the code does not really work for me. What am I missing in the code?
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$P$52" Then Exit Sub
With ActiveSheet
Select Case Target.Value
Case "Horizontal - feet"
.Pictures("B3A").Visible = True
.Pictures("V1A").Visible = False
.Pictures("V1AF").Visible = False
Case "Vertical - simple"
.Pictures("B3A").Visible = False
.Pictures("V1A").Visible = True
.Pictures("V1AF").Visible = False
Case "Vertical - lantern"
.Pictures("B3A").Visible = False
.Pictures("V1A").Visible = False
.Pictures("V1AF").Visible = True
End Select
End With
If Target.Address <> "$P$117" Then Exit Sub
With ActiveSheet
Select Case Target.Value
Case "Right"
.Pictures("3P1").Visible = True
.Pictures("3P1M").Visible = False
Case "Left"
.Pictures("3P1").Visible = False
.Pictures("3P1M").Visible = True
End Select
End With
End Sub
Thanks for your help.
Think through the logic of your if statements causing you to exit the sub.
If the cell is P117, you will hit the first if statement which causes you to exit the sub immediately. So you will never get to your second check.
Embed the logic for each of your operations in if statements like I show here and you will be able to "do something if the cell range is P52 or P117" a bit more appropriately.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
'only do the following operation if your cell address is P52 - don't exit out
'of your entire code if it's not
If Target.Address = "$P$52" Then
With ActiveSheet
Select Case Target.Value
Case "Horizontal - feet"
.Pictures("B3A").Visible = True
.Pictures("V1A").Visible = False
.Pictures("V1AF").Visible = False
Case "Vertical - simple"
.Pictures("B3A").Visible = False
.Pictures("V1A").Visible = True
.Pictures("V1AF").Visible = False
Case "Vertical - lantern"
.Pictures("B3A").Visible = False
.Pictures("V1A").Visible = False
.Pictures("V1AF").Visible = True
End Select
End With
End If
'you skip to down here if it is NOT P52, which then lets you check again to
'see if it's P117
If Target.Address = "$P$117" Then
With ActiveSheet
Select Case Target.Value
Case "Right"
.Pictures("3P1").Visible = True
.Pictures("3P1M").Visible = False
Case "Left"
.Pictures("3P1").Visible = False
.Pictures("3P1M").Visible = True
End Select
End With
End If
End Sub
If you are going to have a lot of checks like this, you may want to create a Select case statement for Target.Address too. It's hard to say which is better for you given what you've asked here.

What are the Integer values of Boolean False and True in VB6?

I'm working with a bit of old VB6 code that goes thus...
Dim STATUS As Integer
STATUS = -1
If (Not STATUS) Then
' do something
Else
' do something else
End If
so I was, naturally, wondering which branch of this code is executed. So does anyone know what the numeric values of True and False are in VB6?
True is stored as -1 and false as 0. Any non-zero value is considered as true.
To see why it is so please check - http://www.vbforums.com/showthread.php?t=405047
In VB 6, True has a numeric value of -1. False has a numeric value of 0.
The reason for this is because the Boolean data type is stored as a 16-bit signed integer. Therefore,-1 evaluates to 16 1s in binary (1111111111111111). False is 16 0s (0000000000000000). This produces the relationship that has held throughout the evolution of BASIC: True = Not False.
Not really an answer, but just poking about, I typed this into the immediate window, with these results:
For x = -5 To 5 : ? x, CBool(x), ( x = True ), ( x = False ) : Next x
-5 True False False
-4 True False False
-3 True False False
-2 True False False
-1 True True False
0 False False True
1 True False False
2 True False False
3 True False False
4 True False False
5 True False False
(I tested more values, but only -1 and 0 had anything "interesting" going on. The rest were all True/False/False.) So, empirically, I'd say that the comparison is being done arithmetically unless you cast with CBool. Why? I can't really say...

Resources