|
|
Usually these IoT display controllers allow you to rotate any direction due to the screen orientation being unknown in advance. In any case, thanks to FueledByDecaf I worked it out by adjusting both the write order and the scan direction both.
Real programmers use butterflies
|
|
|
|
|
|
In my defense this code was generated by a tool. It's still some of the weirdest code to do string ops in SQL I've seen. Part of it is due to the fact that it converts everything to UTF32 as it goes, even though in this routine it really doesn't need to.
DROP PROCEDURE [dbo].[SqlCompiledChecker_IsCommentBlockBlockEnd]
GO
CREATE PROCEDURE [dbo].[SqlCompiledChecker_IsCommentBlockBlockEnd] @value NVARCHAR(MAX), @index INT, @ch INT
AS
BEGIN
DECLARE @adv INT
DECLARE @matched INT
DECLARE @valueEnd INT = DATALENGTH(@value)/2+1
DECLARE @tch BIGINT
DECLARE @accept INT = -1
DECLARE @result INT = 0
WHILE @ch <> -1
BEGIN
SET @matched = 0
IF @ch = 42
BEGIN
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
SET @matched = 1
GOTO q1
END
GOTO next
q1:
IF @ch = 47
BEGIN
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
SET @matched = 1
GOTO q2
END
GOTO next
q2:
RETURN CASE @ch WHEN -1 THEN 1 ELSE 0 END
next:
IF @matched = 0
BEGIN
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
END
END
RETURN 0
END
GO
DROP PROCEDURE [dbo].[SqlCompiledChecker_IsCommentBlock]
GO
CREATE PROCEDURE [dbo].[SqlCompiledChecker_IsCommentBlock] @value NVARCHAR(MAX)
AS
BEGIN
DECLARE @adv INT
DECLARE @ch BIGINT
DECLARE @tch BIGINT
DECLARE @index INT = 0
DECLARE @valueEnd INT = DATALENGTH(@value)/2+1
DECLARE @result INT
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
WHILE @ch <> -1
BEGIN
IF @ch = 47
BEGIN
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
GOTO q1
END
RETURN 0
q1:
IF @ch = 42
BEGIN
SET @index = @index + 1
SET @adv = 1
IF @index < @valueEnd
BEGIN
SET @ch = UNICODE(SUBSTRING(@value, @index, 1))
SET @tch = @ch - 0xd800
IF @tch < 0 SET @tch = @tch + 2147483648
IF @tch < 2048
BEGIN
SET @ch = @ch * 1024
SET @index = @index + 1
SET @adv = 2
IF @index >= @valueEnd RETURN -1
SET @ch = @ch + UNICODE(SUBSTRING(@value, @index, 1)) - 0x35fdc00
END
END
ELSE
BEGIN
SET @ch = -1
END
GOTO q2
END
RETURN 0
q2:
EXEC @result = SqlCompiledChecker_IsCommentBlockBlockEnd @value, @index, @ch
RETURN @result
END
RETURN 0
END
GO
Real programmers use butterflies
|
|
|
|
|
UTF16 ain't good enough for you?
|
|
|
|
|
UTF16 surrogate pairs exist, so no. Frankly, I wish UTF16 didn't exist at all. It seems a waste of everyone's time. No wonder MS adopted it.
Real programmers use butterflies
|
|
|
|
|
code salad.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
With a side of syntax soup.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I'm dying to know what sin in a past life led you to NEED to determine whether the passed in string is a C style comment block - in T-SQL.
Truth,
James
|
|
|
|
|
The comment block was test code. The error of my ways was an outdated idea of restricting access to tables in SQL coupled with stored procedure based field validation, which is where this came in. There is a code generator that produced this particular matcher.
Real programmers use butterflies
|
|
|
|
|
GitHub - roozbehid/WasmWinforms: C# Winforms for Webassembly[^]
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
To quote Peter Lorre's character in The Black Cat segment of Tales of Terror[^]:
"How vomitable!"
Software Zen: delete this;
|
|
|
|
|
If such things can be conceived there is still hope for VB7.
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
den2k88 wrote: If such things can be conceived there is still hope for VB7 The official name for VB7 is "C#".
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
As the title states, recently I have seen very strange behavior using gethostbyname on Windows 10. We are implementing an interface using CIP to talk to a PLC. CIP is a protocol used to talk to industrial I/O devices and PLCs over Ethernet. It has it's own share of weirdness too and is what started all of this. We are talking to Allen Bradley PLCs and it's a real PITA. We configure these "assembly instances" in the PLC and one of their parameters is the IP address of the target computer. To implement the interface we are using a library we bought because the protocol is rather complex. It has this quirk whereby the IP address you configure for your computer will not work directly. To be more precise, it won't work if it is the primary IP address of a NIC. It has to be the secondary address which is configured using the "Advanced Options" of the control panel page for networking. Here is where the really strange part comes in. When I first configure the secondary address for a NIC it won't work. I have to add the address, accept all options, and close the dialogs, then re-open them, delete the address, and close them again. Then I have to re-open the option dialogs and re-enter that address and accept the changes. Only after doing all of that will it work correctly and I have seen this on four different machines. Where gethostbyname comes in is it is called to enumerate the addresses and find a match to the one you ask for. Unless the procedure I described is followed it will not see the secondary address so the interface initialization fails. You can open the dialogs and verify it is there but the function just will not see it unless it is deleted and then added back in.
I don't recall seeing such weirdness before but, of course, this is Windows 10. Yee haw.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Cache? A lot of IP address stuff is cached all over the place. Maybe your magic incantation is what it takes to kick something into a cache refresh.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
try "ipconfig /flushdns" after adding the secondary address
|
|
|
|
|
On Win NT 4.0, the NIC could support a huge number of IPs.
At least 16. The GUI could not handle that many so we would directly edit the registry to add additional IPs.
We may have had to reboot after, but it always worked and sounds easier than your procedure.
|
|
|
|
|
I was told that there's no way to undo an OR as it loses value in the output..
I fumbled upon a formula , to undo an OR
v1 or or_val = ( v1 xor or_val ) + ( v1 and or_val )
100 or 5 = ( (100 or 5) xor 5 ) + ( 100 and 5 )
100 or 10 = ( (100 or 10) xor 10 ) + ( 100 and 10 )
255 or 12 = ( (255 or 12) xor 12 ) + ( 255 and 12 )
|
|
|
|
|
Maybe you should be more clear about what you are saying.
|
|
|
|
|
If you already have both original values in order to "undo" the OR, you've already effectively undone the OR. Or am I missing something? Pretty sure this is an equivalency too, not an undo. If it was an undo it would generate two values from a single OR'd value, or generate a value given an OR'd value and one of the original values.
|
|
|
|
|
But, what's the utility of using this type of syntax to "exec-undo" "dual-values"? 
|
|
|
|
|
To stay with binary logic operations, what your formula boils down to is (using C syntax) :
A | B = ( A ^ B ) | ( A & B ) That is not "undoing" the OR operation. That is a sequence of operations which arrive at the same result. To undo A | B = C you need to perform operations on C with B to give a result of A or operations on C with A that give B.
I find it easier to do binary logic with hexadecimal numbers so with the first numbers,
100 = 0x64
5 = 0x05
0x64 | 0x05 = 0x65 To undo the OR what you need is
0x65 ? 0x05 = 0x64 or
0x65 ? 0x64 = 0x05 I don't know what that expression would be and I can see why you were told it is impossible.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
albert_redditt wrote: I was told that there's no way to undo an OR as it loses value in the output..
That is correct.
Boolean algebra is implemented in programming languages but it still originates from that branch of mathematics.
If you have a value '1' there is no way you will ever be able to tell which of the following statements it originated from.
1 | 1
1 | 0
0 | 1
Because of that you cannot do that you cannot, in a programming language, recover the original values from a value that was created by oring other values together.
|
|
|
|
|
To reverse a OR operation, given on something like
A | B = C
solve for B knowing only A & C.
For example:
6 | B = 7
Given that, B could be 1 or 3 or 5 or 7. Any of those would work in the equation, and there is no way to know which it was.
Truth,
James
|
|
|
|