Faceți căutări pe acest blog

marți, 22 august 2017

Easter eggs (4)

I found a pattern. The keys that are grouped ("neighbors") behaves similarly, especially those in the median part and the right part of the alphanumeric region. I mean it's difficult to catch three of them pressed simultaneously. Any combination of two, or two + other key shows no problem.

Using an US keyboard, the alphanumeric region
4 5 6 7
E R T Y U
D F G H J K
C V B N M ,

0 - = (zero, minus, equal)
P [ ]
L ; '

The numeric keypad
/ * -
0 . 2
0 . 3
1 2 4
1 2 5
2 4 5
a.s.o

The test code used by me (click or press the command button to experiment different combinations):



CLEAR
PUBLIC ofrm
ofrm = CREATEOBJECT("myform")
ofrm.show()

DEFINE CLASS myform as form
      Autocenter = .T.
      l1 = .F. && .T. while key #1 is pressed
      l2 = .F. && .T. while key #2 is pressed
      l3 = .F. && .T. while key #3 is pressed
      ln1 = -1 && Store scan code 1
      ln2 = -1 && Store scan code 2
      ln3 = -1 && Store scan code 3
      ADD OBJECT txt1 as textbox
      ADD OBJECT cmd as commandbutton WITH top = 50, caption = "Reset" && reset the combination
      PROCEDURE init
            UNBINDEVENTS(This.hwnd)
            BINDEVENT(This.hwnd,0x0100,This,"detectkeydown")
            BINDEVENT(This.hwnd,0x0101,This,"detectkeyup")
      ENDPROC
      PROCEDURE detectkeydown
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF This.ln3 = -1 AND !INLIST(This.ln1, -1, m.p3) AND !INLIST(This.ln2, -1, m.p3)
                  This.ln3 = m.p3
            ENDIF
            IF m.p3 = This.ln3
                  This.l3 = .T.
            ENDIF

            IF This.ln2 = -1 AND !INLIST(This.ln1, -1, m.p3)
                  This.ln2 = m.p3
            ENDIF
            IF m.p3 = This.ln2
                  This.l2 = .T.
            ENDIF

            IF This.ln1 = -1
                  This.ln1 = m.p3
            ENDIF
            IF m.p3 = This.ln1
                  This.l1 = .T.
            ENDIF

            ACTIVATE SCREEN
            ? m.p3
            IF This.l1 AND This.l2 AND This.l3
                  ? 'Bingo!'
                  ? 'An ' + LTRIM(STR(This.ln1)) + '+' + LTRIM(STR(This.ln2)) + '+' + LTRIM(STR(This.ln3)) + ' occures'
            ENDIF
                  ACTIVATE SCREEN
            ?This.l1 ,This.l2 ,This.l3
      ENDPROC
      PROCEDURE detectkeyup
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF p3 = This.ln1
                  This.l1 = .F.
            ENDIF
            IF p3 = This.ln2
                  This.l2 = .F.
            ENDIF
            IF p3 = This.ln3
                  This.l3 = .F.
            ENDIF
      ENDPROC
      PROCEDURE cmd.click
            STORE -1 TO ThisForm.ln1, ThisForm.ln2, ThisForm.ln3
            STORE .F. TO ThisForm.l1, ThisForm.l2, ThisForm.l3
      ENDPROC
ENDDEFINE

Update
The previous test was on a Dell keyboard with a US layout (Windows 7 32 bit).
I repeated the same test, but this time using a Fujitsu keyboard with a German layout (Windows 10 prof 64 bit). And what do you know? I managed to catch a 3+4+5. Not easy, but Bingo!
The patterns are almost the same.
Ha! So most probably it's a hardware issue.

Later
A new test using a Genius keyboard (Windows 10 home 32 bit), with an US layout, behaves poorly.
Another test. A HP notebook (Windows 10 home 64 bit) with a Germanic layout, behaves even better than Fujitsu.
A final test using a Lenovo laptop (Windows 10 home 64 bit) with an US layout, behaves poorly.

Again
This article https://en.wikipedia.org/wiki/Rollover_(key) explains everything.

luni, 21 august 2017

ImportFromXlsx 4.0

I've noticed a very odd behavior under Windows Server 2003.
My supposition is that files from folders with more than 8 characters are not extracted form the Zip file, with the help of Namespace.CopyTo()

Update
The real restriction seemed the level of nesting folders.
Under Windows Server 2003, only one level is accepted.
I mean, you can use CopyTo() to extract the content of a folder stored directly in the zip file (including its subfolders), but not the content of a subfolder of a folder.

Example
If the zip file has the following structure:
File1
File2
Folder1/File3
Folder1/Folder2/File4
You can access NameSpace(Folder1).items, but cannot acces NameSpace(Folder1/Folder2).items

Please check this example

Support for LAN Environment added
Solved the infinite loop when is executed under Windows Server

Download link
ImportFromXlsx 4.0


Related posts
http://praisachion.blogspot.com/2016/06/inspectpptx-10.html
http://praisachion.blogspot.com/2016/06/inspectdocx-10.html

MSOffice -> DBF
http://praisachion.blogspot.com/2018/03/appendfromxlsx-31.html
http://praisachion.blogspot.com/2017/08/importfromxlsx-40.html
http://praisachion.blogspot.com/2017/06/append-from-xlsx-30.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-34.html
http://praisachion.blogspot.com/2016/08/importfromxlsx-33.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-32-appendfromxlsx-21.html
http://praisachion.blogspot.com/2016/06/appendfrompptx-10.html
http://praisachion.blogspot.com/2016/06/appendfromdocx-21.html
http://praisachion.blogspot.com/2016/06/importfromdocx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-11.html
http://praisachion.blogspot.com/2016/06/importfromxlsx-31.html
http://praisachion.blogspot.com/2016/06/importfrompptx-10.html
http://praisachion.blogspot.com/2016/06/importfromdocx-30.html
http://praisachion.blogspot.com/2016/05/importfromxlsx-22.html
http://praisachion.blogspot.com/2016/02/import-dbf-from-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/importfromdocx-20.html
http://praisachion.blogspot.com/2016/01/appendfromdocx-20.html
http://praisachion.blogspot.com/2016/01/importfromxlsx-13.html
http://praisachion.blogspot.com/2016/01/appendfromxlsx-20.html
http://praisachion.blogspot.com/2015/12/appendfromxlsx-15.html
http://praisachion.blogspot.com/2015/11/importfromxlsx-13.html
http://praisachion.blogspot.com/2015/09/importfromxlsx-12.html
http://praisachion.blogspot.com/2015/09/appendfromxlsx-14.html
http://praisachion.blogspot.com/2015/09/appendfromnxlsx-13.html
http://praisachion.blogspot.com/2015/08/importfromxlsx-11.html
http://praisachion.blogspot.com/2015/07/import-from-xlsx.html
http://praisachion.blogspot.com/2015/07/insert-from-focx.html
http://praisachion.blogspot.com/2015/06/append-from-docx.html

DBF -> MSOffice
Dbf2Xlsx6 4.2 (VFP6) 
http://praisachion.blogspot.com/2017/04/export-dbf-to-excel-2007.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msexcel-xlsx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-mspowerpoin-pptx.html
http://praisachion.blogspot.com/2017/01/export-dbf-to-msword-docx.html
http://praisachion.blogspot.com/2016/11/export-to-xlsx.html
http://praisachion.blogspot.com/2016/11/export-to-pptx.html
http://praisachion.blogspot.com/2016/11/export-to-docx.html
http://praisachion.blogspot.com/2016/11/export-from-vfp6-to-msoffice-docx-pptx.html
http://praisachion.blogspot.com/2016/09/copytoxlsx6-10.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx_24.html
http://praisachion.blogspot.com/2016/01/export-dbf-to-msoffice-2007-xlsx-docx.html
http://praisachion.blogspot.com/2016/01/exporttopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttodocx-20.html
http://praisachion.blogspot.com/2016/01/copytopptx-20.html
http://praisachion.blogspot.com/2016/01/exporttoxlsx-20.html
http://praisachion.blogspot.com/2016/01/copytoxlsx-30.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-19-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-210-procedure.html
http://praisachion.blogspot.com/2015/12/exporttoxlsx-18-class.html
http://praisachion.blogspot.com/2015/12/copytoxlsx-29.html
http://praisachion.blogspot.com/2015/02/export-pptx-13.html
http://praisachion.blogspot.com/2015/01/copytodocx-12.html
http://praisachion.blogspot.com/2015/01/exportdocx-1.html

OOffice -> DBF
http://praisachion.blogspot.com/2016/11/import-from-openoffice-libreoffice-for.html
http://praisachion.blogspot.com/2016/09/importfromoowrtext-10.html
http://praisachion.blogspot.com/2016/09/importfromooffice-1o.html
http://praisachion.blogspot.com/2016/08/importfromoocalc.html

DBF -> OOffice
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_52.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice_16.html
http://praisachion.blogspot.com/2016/09/copy-to-ods-10-openoffice-calc.html
http://praisachion.blogspot.com/2016/09/export-dbf-to-openoffice-libreoffice.html
http://praisachion.blogspot.com/2016/09/copy-to-odt-10.html

duminică, 20 august 2017

Invalid keys in a TreeView Control

Each node of a TreeView has a key. The key is a string and must be unique [2].
Accidentally I discovered some unacceptable values for this key [3].

Generally, are rejected values that resembles a number:
- Integer literals, like '1'
- Integer literals followed by a period, like '1.'
- Integer literals preceded or folowed by a symbol sign, like '+1' or '1-'
- Numbers with commas between its digits, like '1,' ; '1,1,1' ; '1.,' or '.1,'
- Integer literals preceded or folowed by Space, Tabe or CR

Please try following example.



PUBLIC ofrm
ofrm=CREATEOBJECT("MyForm")
ofrm.show()

DEFINE CLASS MyForm as Form
      autocenter = .T.
      ADD OBJECT teeview as olecontrol WITH oleclass = 'COMCtl.treectrl', width = 300,height = 350
      PROCEDURE init
            LOCAL lcRoot,loRoot
            lcRoot='Root'
            loRoot = thisform.TeeView.Nodes.Add(, 1, m.lcRoot,'Root node')
            loRoot.Expanded = .T.
            * Rejected
            thisform.AddNode(m.lcRoot,'1')
            thisform.AddNode(m.lcRoot,'1.')
            thisform.AddNode(m.lcRoot,'1,')
            thisform.AddNode(m.lcRoot,'+1')
            thisform.AddNode(m.lcRoot,'1.,')
            thisform.AddNode(m.lcRoot,'.1,')
            thisform.AddNode(m.lcRoot,'-1')
            thisform.AddNode(m.lcRoot,'1+')
            thisform.AddNode(m.lcRoot,'1-')
            thisform.AddNode(m.lcRoot,' 1')
            thisform.AddNode(m.lcRoot,'1 ')
            thisform.AddNode(m.lcRoot,CHR(13) + '1')
            thisform.AddNode(m.lcRoot,CHR(9) + '1')
            thisform.AddNode(m.lcRoot,'1,1,1,1')
           
            * Accepted
            thisform.AddNode(m.lcRoot,CHR(13))
            thisform.AddNode(m.lcRoot,CHR(9))
            thisform.AddNode(m.lcRoot,'1 1')
            thisform.AddNode(m.lcRoot,'1E')
            thisform.AddNode(m.lcRoot,'1+1')
      ENDPROC
      PROCEDURE AddNode
            LPARAMETERS lcRoot, lcKey
            LOCAL loErr as Exception
            TRY
                  thisform.TeeView.Nodes.Add(m.lcRoot, 4, m.lcKey,m.lcKey)
            CATCH TO loErr
                  ACTIVATE SCREEN
                  ? m.lcKey, loErr.ErrorNo , loErr.Message
            ENDTRY
      ENDPROC
ENDDEFINE


Bibliography
[1] TreeView Control
[2] Key Property
[3] The code the lead me to these conclusions

Related posts
http://praisachion.blogspot.com/2017/09/correlation-between-margin-and-fontsize.html
http://praisachion.blogspot.com/2017/08/invalid-keys-in-treeview-control.html