Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - moises1953

Pages: [1]
1
Search for DLLs in development and deployment:

In version 1.4 you could declare a DLL simply by name and place it at the executable address, in system32, or at a specified address.

In later versions the IDE has been denying the compilation if the executable is not in QB64, even though the option has been chosen to locate the executables with the sources, and these outside of QB64, which does not seem to be correct.
This is the wiki text: The dynamic library file can be located in the QB64 folder (alongside your programs' .EXE '), in Windows' system32 folder, or in a relative / absolute path specified along with the library name
The consequences that this has in the deployment of an application with DDL's, is that it can no longer be located with the executable, but it can be done:
1. in a QB64 folder, which will have to be created, even if it is not necessary.
2. in system32
3. in a predefined address, for example C: \ AppName, for which it will be necessary to have the same path in the development environment.

Could it be a bug in the IDE?

2
QB64 Discussion / Deployment of application with DLL in Windows 10
« on: May 22, 2021, 02:25:42 am »
Use and deployment of external DLL's in QB64 version 1.4:
The DECLARE DYNAMIC LIBRARY ["DLL name1", "DLL name2", ...] instruction allows the use of any type of dynamic library, both in Windows (DLL) and in Linux (SO), as long as it is declared below the call structure with the correct data types. For example (Windows):
DECLARE DYNAMIC LIBRARY "kernel32"
  FUNCTION GetThreadUILanguage% ()
  FUNCTION LCIDToLocaleName% (BYVAL LCID &, lcidName $, BYVAL length%, BYVAL dwFlags ~ &)
  FUNCTION GetUserDefaultLocaleName% (pwsLocale $, BYVAL LocaleLength%)
END DECLARE

These language functions are in the Windows 'kernel32' module, but since they have not been used by QB64, they need to be declared, as well as the call structure of the functions to use.
To use a library from a provider, it should be enough to copy it to the application folder, and call it by its name, without more, for example:
DECLARE DYNAMIC LIBRARY "NmxDLLx64"
 SUB NMX_GetDllVersion_1 (usMajor ~%, usMinor ~%, usPatch ~%, usBuild ~%)

Unfortunately, if it is only in the application folder, the IDE cannot find it and therefore does not allow it to be compiled, so it is necessary to copy it to system32 for the IDE to find it. On the other hand, the use of a relative location address such as ". \ NmxDLLx64" makes it work when compiling, but not when deploying the application, since the absolute address is resolved at compile time and makes the application not find the DLL in its own folder, but instead looks for the address where it was located when it was compiled.
For the generated executable to be able to use an external library with a simple name declaration, it must be located in C: \ windows \ system32 or in the same folder as the application, and this is sufficient for most cases, But for the IDE to find it and allow compiling, it must be in system32, however the generated executable will look for it in the application folder itself, so it will be enough to copy the application and the DLL together.
In my opinion it is necesary to make the IDE look like the executable.

3
QB64 Discussion / Deployment of application with DLL in Windows 10
« on: March 18, 2021, 03:42:33 am »
Environment:
64-bit Windows 10 version 2004 PC. 64-bit QB64 is installed, and a dynamic library named NmxDLLx64.DLL is added, which as its name indicates is 64-bit, in the same folder as the executable.
A program is created that uses the library without problem, even if it is copied to another folder
Library declaration
DECLARE DYNAMIC LIBRARY ". \ NmxDLLx64"

Laptop with Windows 10 version 1909 64-bit. Do not have QB64 installed.

Tests:
1) Copy program and DLL to laptop and run. Result: Cannot find the DLL (popup with message: 'Cannot find dynamic library file'.
2) Install QB64 on laptop. Copy the source of the program and compile it. Then the program works correctly.
3) Copy the executable again from the PC and run. The message box not found message appears again.
4) Create on the PC a path equal to the destination of the laptop where I want to install the application and its DLL. Compile it there. Copy it to the laptop and now it works.
5) One last test: Rename the folder where the executable and the DLL are located and it stops working

Conclusion:
The load address of the DLL is resolved in the compilation and linking process, from unit level.
Therefore, to deploy the application with its DLL, it must be copied to the same address relative to the computer that it was occupying when it was compiled.

¿There is another option?

4
QB64 Discussion / Flush File Buffers
« on: August 01, 2020, 02:59:00 am »
Windows has a FlushFileBuffers function to move the pending data from cache to file, without closing the file:
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers
I'm interested in implement this function but need the windows file handle, and FILEATTR has not been implemented.
There is any way to perform fileflushing?.
Posible to add a _FILEFLUSH statement (or similary) to QB64?

5
Display of special characters and keyboard mapping are a pending subject in QB64. It applies to both the IDE and the INKEY $, KEYHIT, INPUT ... functions.
Regardless of the IDE language that is selected, the screen output uses the CP437. So if you configure Windows CP1250, you can see what you write, but when you run the program it will show the character corresponding to the extended ASCII code represented by CP437. Therefore, the page chosen for the IDE is not taken into account to generate the text outputs of the compiled program, therefore it is useless to choose another one than CP437. And so it should be to preserve compatibility.
Regarding the presentation, let's take an extended character from page CP437, for example º has the code 167, however when typing º on a Spanish keyboard you receive, both in the IDE and in the executables, with the code 186 that represents as ║, and therefore should be mapped to  167 to show º.
As for the keyboard, some [AltGr] keys, like {} [] work well in the IDE, but not in the INPUT, and in neither case can you type accented letters, which requires a KEYHIT process.
I am attaching an example for a Spanish keyboard.
Code: QB64 $NOPREFIX: [Select]
  1. DEFLNG H-P
  2. 'CONST Phor = 1366, Pver = 768 ' WXGA
  3. CONST Phor = 1600, Pver = 900 ' HD+
  4.  
  5. TITLE "Inkeyhit" 'Version 1.0
  6. hscr = NEWIMAGE(Phor, Pver, 256)
  7. SCREEN hscr
  8. 'Permite comprobar el mapeado del teclado.
  9.  
  10. PuedeFull = (Pver = DESKTOPHEIGHT)
  11. 'Para poner a pantalla completa basta pulsar <Alt><Intro> un par de veces.
  12.  
  13. fontpath$ = "Lucon.ttf": fontsize% = 24 'Windows lucida console 24x14
  14. style$ = "MONOSPACE"
  15. hfont = LOADFONT(fontpath$, fontsize%, style$)
  16. IF hfont THEN FONT hfont
  17.  
  18. LOCATE , , 1 'mostrar cursor solo funciona en modo texto
  19. PRINT "Inkeyhit & display (128-175): €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯"
  20. PRINT "                   (176-223): °±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß"
  21. PRINT "CP437 extended     (224-254): àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ"
  22. PRINT "Puede comprobar si el mapeado del teclado es correcto"
  23. PRINT CHR$(254);
  24. LOCATE , 1
  25.   in$ = Inkeyhit$ 'emulates quickbasic INKEY$
  26.   IF LEN(in$) THEN
  27.     PRINT in$;
  28.     pcol = POS(0)
  29.     PRINT CHR$(254);
  30.     LOCATE , pcol
  31.   END IF
  32. LOOP UNTIL in$ = CHR$(27)
  33.  
  34. FUNCTION Inkeyhit$ STATIC 'Emulates INKEY$ for spanish keyboard
  35.   DIM i, iaccent AS INTEGER, car AS UNSIGNED BYTE, doblecar AS STRING * 2
  36.   i = KEYHIT
  37.   IF i THEN
  38.     car = 0
  39.     keyalt = KEYDOWN(100307) OR KEYDOWN(100308)
  40.     keyctrl = KEYDOWN(100305) OR KEYDOWN(100306)
  41.     keyshift = KEYDOWN(100303) OR KEYDOWN(100304)
  42.     IF iaccent THEN
  43.       SELECT CASE iaccent
  44.         CASE 1
  45.           SELECT CASE i
  46.             CASE 97: car = 160 '
  47.             CASE 101: car = 130 '‚
  48.             CASE 105: car = 161 '¡
  49.             CASE 111: car = 162 '¢
  50.             CASE 117: car = 163 '£
  51.             CASE 69: car = 144 '
  52.           END SELECT
  53.         CASE 2
  54.           SELECT CASE i
  55.             CASE 97: car = 133 '…
  56.             CASE 101: car = 138 'Š
  57.             CASE 105: car = 141 '
  58.             CASE 111: car = 149 '•
  59.             CASE 117: car = 151 '—
  60.           END SELECT
  61.         CASE 3
  62.           SELECT CASE i
  63.             CASE 97: car = 132 '„
  64.             CASE 101: car = 137 '‰
  65.             CASE 105: car = 139 '‹
  66.             CASE 111: car = 148 '”
  67.             CASE 117: car = 129 '
  68.             CASE 65: car = 142 'Ž
  69.             CASE 79: car = 153 '™
  70.             CASE 85: car = 154 'š
  71.           END SELECT
  72.         CASE 4
  73.           SELECT CASE i
  74.             CASE 97: car = 131 'ƒ
  75.             CASE 101: car = 136 'ˆ
  76.             CASE 105: car = 140 'Œ
  77.             CASE 111: car = 147 '“
  78.             CASE 117: car = 150 '–
  79.           END SELECT
  80.       END SELECT
  81.     END IF
  82.  
  83.     IF car = 0 THEN
  84.       SELECT CASE i
  85.         CASE 48 TO 57 'numeric heys 0-9
  86.           IF keyalt = 0 THEN car = i
  87.         CASE 97 TO 122 'CTRL a-z: 1-26
  88.           car = i
  89.           IF keyctrl THEN car = car - 96
  90.         CASE 128: car = 238 '€î   'spanish keyboard keys maping
  91.         CASE 161: car = 173 '¡­
  92.         CASE 170: car = 166 'ª¦
  93.         CASE 183: car = 249 '·ù
  94.         CASE 186: car = 167 'º§
  95.         CASE 191: car = 168 '¿¨
  96.         CASE 199: car = 128 'ç€
  97.         CASE 209: car = 165 'Ñ¥
  98.         CASE 231: car = 135 'ç‡
  99.         CASE 241: car = 164 'ñ¤
  100.         CASE 1 TO 255
  101.           car = i
  102.         CASE 256 TO 65535 'double byte chr$(0)+
  103.           doblecar = MKI$(i&)
  104.           car = ASC(doblecar, 2)
  105.           IF keyalt THEN
  106.             SELECT CASE car
  107.               CASE 59 TO 68 'F1-F10: ;-D
  108.                 MID$(doblecar, 2) = CHR$(car + 45)
  109.               CASE 133, 134 'F11,F12; …,†
  110.                 MID$(doblecar, 2) = CHR$(car + 6)
  111.               CASE ELSE
  112.                 MID$(doblecar, 2) = CHR$(0)
  113.             END SELECT
  114.           ELSEIF keyctrl THEN
  115.             SELECT CASE car
  116.               CASE 59 TO 68 'F1-F10: ^-g
  117.                 MID$(doblecar, 2) = CHR$(car + 35)
  118.               CASE 71 'Home
  119.                 MID$(doblecar, 2) = CHR$(119)
  120.               CASE 73 'RePag
  121.                 MID$(doblecar, 2) = CHR$(132)
  122.               CASE 75 'Left
  123.                 MID$(doblecar, 2) = CHR$(115)
  124.               CASE 77 'Right
  125.                 MID$(doblecar, 2) = CHR$(116)
  126.               CASE 79 'End
  127.                 MID$(doblecar, 2) = CHR$(117)
  128.               CASE 81 'AvPag
  129.                 MID$(doblecar, 2) = CHR$(118)
  130.               CASE 133, 134 'F11,F12
  131.                 MID$(doblecar, 2) = CHR$(car + 4)
  132.               CASE ELSE
  133.                 MID$(doblecar, 2) = CHR$(0)
  134.             END SELECT
  135.           ELSEIF keyshift THEN
  136.             SELECT CASE car
  137.               CASE 59 TO 68 'F1-F10
  138.                 MID$(doblecar, 2) = CHR$(car + 25)
  139.               CASE 71 TO 81
  140.               CASE 133, 134 'F11,F12
  141.                 MID$(doblecar, 2) = CHR$(car + 2)
  142.               CASE ELSE
  143.                 MID$(doblecar, 2) = CHR$(0)
  144.             END SELECT
  145.           END IF
  146.           IF CVI(doblecar) THEN
  147.             Inkeyhit$ = doblecar
  148.             iaccent = 0
  149.           END IF
  150.           car = 0
  151.         CASE -100308 'Alt up
  152.           IF LEN(buf$) THEN
  153.             car = VAL(buf$)
  154.             buf$ = ""
  155.           END IF
  156.         CASE -222 'accent and dieresis
  157.           IF keyshift THEN
  158.             iaccent = 3
  159.           ELSE
  160.             iaccent = 1
  161.           END IF
  162.         CASE -186 'backaccent and circumflex
  163.           IF keyshift THEN
  164.             iaccent = 4
  165.           ELSE
  166.             iaccent = 2
  167.           END IF
  168.         CASE -57 TO -48 'numeric keys, also numeric keypad with numlock
  169.           IF keyalt THEN
  170.             IF LEN(buf$) > 2 THEN buf$ = RIGHT$(buf$, 2)
  171.             buf$ = buf$ + CHR$(ABS(i&))
  172.           END IF
  173.       END SELECT
  174.     END IF
  175.     IF car THEN
  176.       Inkeyhit$ = CHR$(car)
  177.       iaccent = 0
  178.     END IF
  179.   END IF
  180.  

6
QB64 Discussion / Mousemove bug on fullscreen mode
« on: May 30, 2020, 05:53:44 am »
Bug: MOUSEMOVE on FULLSCREEN works in Desktop coordinates, but can't exceed screen coordinates.
If your Screen resolution and Desktop resolution are equal, works OK.
Else if your app runs on her window, also works OK.
But if you use [Alt][Enter] to put it in FULLSCREEN mode, you can't use de readed mouse coordinates to MOUSEMOVE, so you need to reescale.

Example: fine mouse move with keyboard arrows
Code: QB64: [Select]
  1. 'fine mouse move with arrows
  2. 'Bug: MOUSEMOVE on FULLSCREEN works in Desktop coordinates,
  3. '     but can't exceed screen coordinates
  4. 'press [Alt][Enter] to show FULLSCREEN
  5. DEFLNG H-P
  6. PhDtp = DESKTOPWIDTH
  7. PvDtp = DESKTOPHEIGHT
  8.  
  9. PixHor = 1366: PixVer = 768
  10. 'PixHor = 1728: PixVer = 972
  11.  
  12. SCREEN NEWIMAGE(PixHor, PixVer, 256)
  13. 'FULLSCREEN , SMOOTH
  14. SCREENMOVE 0, 0
  15. pxcenter = PixHor \ 2
  16. pycenter = PixVer \ 2
  17.  
  18. PhCar = FONTWIDTH
  19. PvCar = FONTHEIGHT
  20. pyps = PixVer - PvCar
  21.  
  22. LOCATE 1, 1
  23. PRINT "Desktop:"; PhDtp; PvDtp; "Screen:"; PixHor; PixVer
  24. ifull = FULLSCREEN
  25. LOCATE 1, 48: PRINT "FULL:"; ifull
  26. PRINT "Use Keyboard arrors to fine position the mouse cursor, press any key to mark with +, [Backspace] to retrive last mark, click to draw."
  27. PRINT "Test in FULLSCREEN, presing [Alt][Enter]: Now MOUSEMOVE works on Desktop coordinates"
  28.  
  29. mx = 0
  30. my = 0
  31. markx = PixHor \ 2
  32. marky = PixVer \ 2
  33. MOUSESHOW
  34. MOUSEMOVE pxcenter, pycenter 'center mouse
  35. PRINTSTRING (pxcenter - PhCar \ 2, pycenter - PvCar \ 2), "X"
  36.   nfull = FULLSCREEN
  37.   IF nfull - ifull THEN
  38.     LOCATE 1, 53: PRINT nfull
  39.     ifull = nfull
  40.   END IF
  41.   DO WHILE MOUSEINPUT
  42.     mx = MOUSEX
  43.     my = MOUSEY
  44.     mClick = MOUSEBUTTON(1)
  45.     ' mouseRight = MOUSEBUTTON(2)
  46.     ' mouseMiddle = MOUSEBUTTON(3)
  47.     ' MOUSEWHEEL
  48.     PRINTSTRING (0, pyps), STR$(mx) + STR$(my) + SPACE$(6)
  49.  
  50.     IF mClick THEN
  51.       PSET (mx, my)
  52.       PRINTSTRING (120, pyps), "Click:" + STR$(mx) + STR$(my) + SPACE$(6)
  53.     END IF
  54.   LOOP
  55.  
  56.   in$ = INKEY$
  57.   IF LEN(in$) THEN
  58.     '...  capture arrows & do mouse move
  59.     SELECT CASE in$
  60.       CASE CHR$(0) + "H" 'Up
  61.         IF my THEN move = 1 ELSE move = 0
  62.       CASE CHR$(0) + "K" 'Left
  63.         IF mx THEN move = 2 ELSE move = 0
  64.       CASE CHR$(0) + "M" 'Right
  65.         IF mx + 1 < PixHor THEN move = 3 ELSE move = 0
  66.       CASE CHR$(0) + "P" 'Down
  67.         IF my + 1 < PixVer THEN move = 4 ELSE move = 0
  68.       CASE CHR$(8) 'Backspace
  69.         move = 9
  70.       CASE ELSE
  71.         PRINTSTRING (mx - PhCar \ 2, my - PvCar \ 2), "+"
  72.         markx = mx: marky = my
  73.     END SELECT
  74.  
  75.     IF move THEN
  76.       mxi = mx: myi = my
  77.       PRINTSTRING (380, pyps), "Last move:" + STR$(move)
  78.       IF FULLSCREEN THEN '1:stretch, 2:squarepixels
  79.         mxmovi = CINT(mx * PhDtp / PixHor) 'scale conversion for mousemove
  80.         mymovi = CINT(my * PvDtp / PixVer)
  81.  
  82.         SELECT CASE move
  83.           CASE 1: my = my - 1
  84.           CASE 2: mx = mx - 1
  85.           CASE 3: mx = mx + 1
  86.           CASE 4: my = my + 1
  87.           CASE 9
  88.             mx = markx
  89.             my = marky
  90.           CASE ELSE
  91.         END SELECT
  92.         mxmov = CINT(mx * PhDtp / PixHor)
  93.         mymov = CINT(my * PvDtp / PixVer)
  94.         IF mxmov >= PixHor THEN move = 0
  95.         IF mymov >= PixVer THEN move = 0
  96.         IF move THEN
  97.           PRINTSTRING (480, pyps), STR$(mxmov) + STR$(mymov) + SPACE$(6)
  98.           MOUSEMOVE mxmov, mymov
  99.         ELSE
  100.           PRINTSTRING (480, pyps), STR$(mxmovi) + STR$(mymovi) + SPACE$(6)
  101.           mx = mxi: my = myi
  102.         END IF
  103.       ELSE
  104.         SELECT CASE move
  105.           CASE 1: my = my - 1
  106.           CASE 2: mx = mx - 1
  107.           CASE 3: mx = mx + 1
  108.           CASE 4: my = my + 1
  109.           CASE 9
  110.             mx = markx
  111.             my = marky
  112.           CASE ELSE
  113.         END SELECT
  114.         PRINTSTRING (480, pyps), STR$(mx) + STR$(my) + SPACE$(6)
  115.         MOUSEMOVE mx, my
  116.       END IF
  117.       move = 0
  118.     END IF
  119.   END IF
  120. LOOP UNTIL in$ = CHR$(27)
  121.  

7
Contrary to INKEY$ function of Quickbasic, wich performs very well, the INKEY$ function of QB64 was unable to capture accented vowels, like 'áéíóú'.
Also INKEY$ was unable to capture to capture the <AltGr> symbols, and the spanish 'ñ'  or the french 'ç'.
I think this is a bug.
However some maping is posible:
Code: QB64: [Select]
  1. FUNCTION Inkeymap$
  2.   in$ = INKEY$
  3.   IF LEN(in$) THEN
  4.     SELECT CASE ASC(in$)
  5.       CASE 0
  6.         IF LEN(in$) = 2 THEN '...spanish keyboard
  7.           SELECT CASE ASC(in$, 2)
  8.             CASE 26: in$ = "["
  9.             CASE 27: in$ = "]"
  10.             CASE 43: in$ = "\"
  11.             CASE 121: in$ = "@"
  12.             CASE 122: in$ = "#"
  13.             CASE ELSE
  14.           END SELECT
  15.         END IF
  16.       CASE 161: in$ = CHR$(173) '"¡­"
  17.       CASE 170: in$ = CHR$(166) '"ª"
  18.       CASE 186: in$ = CHR$(167) '"º"
  19.       CASE 191: in$ = CHR$(168) '"¿"
  20.       CASE 209: in$ = CHR$(165) '"Ñ"
  21.       CASE 231: in$ = CHR$(128) '"ç"
  22.       CASE 241: in$ = CHR$(164) '"ñ"
  23.       CASE ELSE
  24.     END SELECT
  25.   END IF
  26.   Inkeymap$ = in$
  27.  

Pages: [1]