What are the Integer values of Boolean False and True in VB6? - 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...

Related

vbs inputbox mandatory text [duplicate]

When I run the following snippet, and enter an acceptable value, I get the desired result.
do while len(strselect) = 0 'or strselect<>"1" or strselect<>"2" or strselect<>"3"
strselect = inputbox ("Please select:" &vbcrlf&vbcrlf&_
"1. Add an entry" &vbcrlf&vbcrlf&_
"2. Remove an entry" &vbcrlf&vbcrlf&_
"3. Search for an entry" &vbcrlf, "Contact Book")
if isempty(strselect) then
wscript.quit()
elseif strselect="1" then
wscript.echo "You chose 1"
elseif strselect="2" then
wscript.echo "You chose 2"
elseif strselect="3" then
wscript.echo "You chose 3"
end if
loop
However if I try constrain the validation process further (by including the remark in the do while conditions), and run the snippet again, I get the corresponding if condition triggered, but the do loop continues, instead of exiting.
I've tried using isnumeric and cstr on the do loop strselect conditions, with no joy... What am I missing to get the darn thing to exit the loop?
You have a problem with the logic in the condition
condition 1 condition 2 condition 3 condition 4
v----------------v v------------v v------------v v............v
do while len(strselect) = 0 or strselect<>"1" or strselect<>"2" or strselect<>"3"
Depending on value inside strselect, you have
value c1 c2 c3 c4
len=0 <>"1" <>"2" <>"3" c1 or c2 or c3 or c4
-------------------------------------- --------------------
empty true true true true true
1 false false true true true
2 false true false true true
3 false true true false true
other false true true true true
In each line you have at least one condition evaluated as true, and as you are concatenating the conditions with Or operators (evaluate to true if at least one of the values is true), the full condition is evaluated as true and the code keeps looping
You only need to change the condition
Do While strselect<>"1" And strselect<>"2" And strselect<>"3"
Do While Not (strselect="1" Or strselect="2" Or strselect="3")
....

Why do I get both true and false for this Prolog comparison?

regions([a,b,c,d,e,f]).
colors([brown,green,blue,red]).
hascolor(X,brown):-regions([X|_]).
hascolor(X,brown):-regions([_,_,_,_,X,_]).
hascolor(X,blue):-regions([_,X,_,_,_,_]).
hascolor(X,blue):-regions([_,_,_,X,_,_]).
hascolor(X,green):-regions([_,_,_,_,_,X]).
hascolor(X,red):-regions([_,_,X,_,_,_]).
conflict(X,Y):-hascolor(X,brown),hascolor(Y,brown).
Hey guys running ?-conflict(a,e). would get me true and false. Both a and e has the same color(brown) and conflict should return true only. Why does it return false also?

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.

Clang xcode code formatter puts new line

I installed Clang for xcode and formatted my code with it
everything seems fine, except if the class name is too long for a property, it goes to the next line
is there a setting i can put to prevent that?
#property(nonatomic, strong) <==bad (the new line)
UITableViewDelegate *invoiceListTableViewDelegate;
#property(nonatomic, strong) NSDate *lastCall; <== good
here is my property file:
---
# BasedOnStyle: LLVM
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
ColumnLimit: 250
ConstructorInitializerAllOnOneLineOrOnePerLine: false
DerivePointerBinding: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: false
Standard: Cpp03
IndentWidth: 2
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
...
It sounds like you want to uncheck the line wrapping checkbox in your Xcode "Text Editing" preferences:

JQGrid - Load at Once not loading in a correct order

I am using JQGrid version 4.1.2. With this I am facing some problems in tree grid while using Adjacency model (Load at once). I Am loading the JSON data from a server. Tree grid is getting formed according to the row order from JSON data. Say for ex: I am forming tree grid for Branch & Department. In my query I am not able to sort according to the parent child hierarchy, because around 6 tables I need to join. But I can get the records with proper id, parent, level & is_leaf properties.
What the grid is doing means - just its creating the rows from JSON whatever order it is. So the tree format is not coming up properly. When I click the root node of any department, it's collapsing the correct child but all children are under different parent(according to my JSON order).
Below is the data which I am getting as a JSON from my server.
id name level parent is_leaf expanded loaded
—– —————–—– —–—–—– —–—–—–—– —–—–—–—– —–—–—–—–—– —–—–—–—–—–
B1 Shanghai Pvt Ltd 1 (null) false true true
D3 Finance & Account 2 B1 true true true
D4 Production 2 B1 true true true
D5 Support 2 B1 true true true
D6 Operation 2 B1 false true true
D13 Software 2 B1 true true true
D82 BPO 2 B1 false true true
D76 Sub D12 3 D1 true true true
D75 Sub D11 3 D1 true true true
D78 Sub D21 3 D2 false true true
D84 Operation1 3 D6 true true true
D83 BPO1 3 D82 false true true
D79 Sub D211 4 D78 false true true
D87 BPO11 4 D83 true true true
D80 Sub D2111 5 D79 true true true
D1 Admin 2 B1 false true true
D2 Sales 2 B1 false true true
B13 Beijing Pvt Ltd 1 (null) false true true
D86 Test 2 2 B13 false true true
D134 Test Root 2 B13 true true true
D91 Test Level 1 3 D85 false true true
D93 Test 2 Level 1 3 D86 true true true
D133 Test Level 3 5 D92 true true true
D92 Test Level 2 4 D91 false true true
D85 Test 2 B13 false true true
B14 Branch Office 3 1 (null) false true true
D132 Software 2 B14 false true true
D95 Level 1 3 D132 true true true
D94 Root 2 B14 true true true
D136 Level 2 3 D132 true true true
B15 Branch Office 4 1 (null) true true true
Inside jqgrid function I've defined all of these.
treeGrid: true,
treeGridModel:'adjacency',
ExpandColumn : 'deptName'
Is there anything I am missing/doing wrong, or this is how tree grid works right now?
When using TreeGrid the json data needs to be sorted in the way it will be displayed.
All the child nodes need to be under the parent in the json data. This is a limitation of TreeGrid.
In my opinion, the tree should render based on the associations already defined in the data being returned from the server
I have never implemented treeGrid in jqgrid, but i'll advise you to check these references
http://www.ok-soft-gmbh.com/jqGrid/LocalAdjacencyTree8.htm
see the example on http://trirand.com/blog/jqgrid/jqgrid.html > New in 3.4 > Tree grid Adjacency Model
and this answer Sorting of jqGrid (v4.1.2) treegrid not working with Ajacency Model
from Oleg.

Resources