Author Topic: ScriptBasic Windows 64 Bit  (Read 1811 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #15 on: August 20, 2021, 10:24:42 pm »
I'm not using MySQL. Only Postgres and MS SQL 64 bit servers.

This is a good example why I've given up on Windows 64 and SB in the past. IUP has issues as well running 64 bit.
« Last Edit: August 20, 2021, 10:47:55 pm by John »

Offline AIR

  • BASIC Developer
  • Posts: 817
Re: ScriptBasic Windows 64 Bit
« Reply #16 on: August 21, 2021, 02:16:56 pm »
This is a good example of what happens when you DON'T follow the API Documentation.

The issue boils down to not properly using the defined TYPES for a library.

For example, using char in place of SQLCHAR.

Another example, which is the reason for the truncated output, is using SQLINTEGER when the correct type is SQLLEN (which automagically accounts for 32 vs 64 bit).

In essence, the function prototypes that the Microsoft SQL Team provide were not adhered to, resulting in the issues under 64Bit.


After making the changes to the variable TYPES, I can connect to and query a MS SQL Express DB (running on my Linux server in a Docker container) with no issues.  In the call to ::RealConnect, I had to provide user/password to connect.


See the attached patch file, run it against the odbc/interface.c from the SB64 archive I sent you, since I don't know what you may have changed in your own local copy.

AIR.


Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #17 on: August 21, 2021, 04:40:37 pm »
Thanks AIR!

I'll give this a try.

You are a wizard. Nothing gets by you.  8)
« Last Edit: August 21, 2021, 04:47:24 pm by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #18 on: August 21, 2021, 06:46:50 pm »
You're the man!

It now works with Postgres SQL 64 bit ODBC. I will give MS SQL server a try as well.

Code: Script BASIC
  1. IMPORT odbc.sbi
  2.  
  3. dbh = odbc::RealConnect("BIO64U","","")
  4. SQL = "SELECT * FROM ar_customer LIMIT 10"
  5. odbc::query(dbh, SQL)
  6. WHILE odbc::Fetchhash(dbh, column)
  7.   PRINT column{"customerno"}," - ",column{"customername"},"\n"
  8. WEND
  9.  
  10. odbc::Close(dbh)
  11.  


C:\ScriptBasic\examples>sbc psql_64.sb
12THMT0 - 12th Man Technologies
AAARBA7 - AAARBA
AABING6 - A.A. Bin Hindi Group
AABS184 - Armstrong Atl St Univ Biol
AABS999 - Armstrong Atl St Univ
AABWTP8 - abr American Business Review
AAC7060 - Anne Arundel CC Biol
AACH476 - Uniklinik RWTH Aachen
AACHEN7 - Universitatsklinikum Aachen
AADUNA8 - Alberto Aduna

C:\ScriptBasic\examples>


I added the change you made to FetchHash to FetchSchema as it is basically a copy of that routine.

Code: C
  1. besFUNCTION(odbc_fetchschema)
  2.   VARIABLE Argument;
  3.   LEFTVALUE Lval;
  4.   podbcHANDLE q;
  5.   int i;
  6.   unsigned long __refcount_;
  7.   podbcOBJECT p;
  8.   // char *pszColNameBuffer;
  9.   SQLCHAR *pszColNameBuffer;
  10.   SQLSMALLINT cbColNameBuffer;
  11.   SQLSMALLINT cbrColNameBuffer;
  12.   SQLSMALLINT DataType;
  13.   // SQLUINTEGER ColSize;
  14.   SQLULEN ColSize;
  15.   SQLSMALLINT DecimalDigits;
  16.   SQLSMALLINT Nullable;
  17.   SQLRETURN ret;
  18.   int iError;
  19.   int typesize;
  20.  

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #19 on: August 21, 2021, 07:43:39 pm »
I can't get any of the 3 MS SQL ODBC drivers to configure without blowing up in the ODBC 64 bit configuration when try test connection.

What ODBC driver did you use to connect to MS SQL Express?

I download the 64 bit MS ODBC driver version 17. Same problem


Microsoft ODBC Driver for SQL Server Version 17.08.0001

Running connectivity tests...

Attempting connection
[Microsoft][ODBC Driver 17 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
[Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
[Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

TESTS FAILED!

« Last Edit: August 21, 2021, 08:11:19 pm by John »

Offline AIR

  • BASIC Developer
  • Posts: 817
Re: ScriptBasic Windows 64 Bit
« Reply #20 on: August 21, 2021, 09:32:53 pm »
The standard 64bit SQL Server driver that comes with Windows 10.



Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #21 on: August 21, 2021, 10:02:12 pm »
It seems I had a couple versions of MS SQL Server installed. I uninstalled everything and reinstall Express. I still can't get a 64 bit ODBC driver configured without errors. The 32 bit driver configure works without issue.

I give up. I can't get a MS SQL Server 64 bit ODBC driver to configure.

The 32 bit setup works without any problems.
« Last Edit: August 21, 2021, 10:22:30 pm by John »

Offline AIR

  • BASIC Developer
  • Posts: 817
Re: ScriptBasic Windows 64 Bit
« Reply #22 on: August 21, 2021, 10:38:47 pm »
This is the second time in this thread that you've 'given up'.

You're choice to stay on 32bit, but I'm done.  Moving on to a better language.....

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #23 on: August 21, 2021, 10:44:54 pm »
Please don't give up on SB.

The work you did on the SB 64 ODBC extension module worked. (PSQL64)

I'll figure it out, just frustrated at the moment.

I'm going to try it on my older test laptop that is pretty much virgin Windows 10 Pro.
« Last Edit: August 21, 2021, 10:54:34 pm by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #24 on: August 22, 2021, 12:37:00 pm »
I got it working on MS SQL Server on my development laptop. It looks like 64 bit doesn't like a TCP/IP connection. (couldn't be found error) Named pipes solved the problem. TCP works fine when configuring the driver for 32 bit access.

My guess is that 64 bit MS SQL Server ODBC dynamic port selection is either selecting a port already in use or it's a firewall issue. What is the default port for MS SQL Server?

I tried to allow the TCP and UDP ports with these PowerShell commands but it only works with Named Pipe.

New-NetFirewallRule -DisplayName "SQLServer default instance" -Direction Inbound -LocalPort 1433 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "SQLServer Browser service" -Direction Inbound -LocalPort 1434 -Protocol UDP -Action Allow
« Last Edit: August 22, 2021, 01:34:02 pm by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #25 on: August 22, 2021, 01:41:16 pm »
AIR,

I know you're not a Windows 32 bit fan but my clients still use 32 bit accounting software with OLE Automation. If I want to get paid I still need to support a 32 bit SB.

I'm excited to see we are making progress on the 64 bit SB front. cURL and ODBC where two modules holding me back with 64 bit SB. We are now past that wall.
« Last Edit: August 22, 2021, 02:08:54 pm by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #26 on: August 22, 2021, 11:20:28 pm »
I was able to get TCP working with MS SQL Server 64 bit. It seems TCP was disabled for 64 bit but enable for 32 bit. I enabled TCP and now creating a 64 bit DSN works for MS SQL Server.

Step 6 - Check that TCP/IP and Named Pipes are enabled

Check the TCP/IP and Named Pipes protocols and port. Open SQL Server Configuration Manager and check the SQL Server Network Configuration protocols. You should enable Named Pipes and TCP/IP protocol.

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #27 on: August 23, 2021, 01:21:27 pm »
AIR,

I'm working on trying to get IUP working with SB 64 bit. I also plan to do direct callbacks to SB rather than the loop step wait method I'm using now.



« Last Edit: August 23, 2021, 02:41:52 pm by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #28 on: August 26, 2021, 07:00:49 pm »
I was able to compile an IUP extension module for 64 bit Windows but the module won't load with ScriptBasic. Not sure why yet. IUP/CD/IM was combined into the C:\iup64 directory. I'm using TDM-GCC-64. Here is my Makefile.

Code: Bash
  1.  
  2. all : pui.a pui.dll
  3.  
  4. pui.a : bin\mod\obj\pui\s_interface.o
  5.         ar -r ..\..\bin\mod\lib\pui.a ..\..\bin\mod\obj\pui\s_interface.o C:\iup64\libiup.a C:\iup64\libiupcd.a C:\iup64\libiupcontrols.a C:\iup64\libiupimglib.a C:\iup64\libfreetype6.a C:\TDM-GCC-64\x86_64-w64-mingw32\lib\libws2_32.a C:\TDM-GCC-64\x86_64-w64-mingw32\lib\libadvapi32.a
  6.  
  7. pui.dll : bin\mod\obj\pui\interface.o
  8.         gcc -Wno-write-strings -pipe -shared -w -s -O2 -m64 -Wl,--add-stdcall-alias,--output-def,"..\..\bin\mod\dll\pui_imp.def",--out-implib,"..\..\bin\mod\dll\pui_imp.a" -o ..\..\bin\mod\dll\pui.dll ..\..\bin\mod\obj\pui\interface.o -LC:\iup64 -IC:\iup64\include -liup -liupcd -liupcontrols -liupimglib -lfreetype6 -lws2_32 -ladvapi32
  9.  
  10. bin\mod\obj\pui\interface.o : interface.c
  11.         gcc -w -D_WIN32 -m64 -c -LC:\iup64 -IC:\iup64\include -o ..\..\bin\mod\obj\pui\interface.o interface.c
  12.  
  13. bin\mod\obj\pui\s_interface.o : interface.c
  14.         gcc -w -D_WIN32 -m64 -c -LC:\iup64 -IC:\iup64\include -o ..\..\bin\mod\obj\pui\s_interface.o interface.c
  15.  

Offline John

  • Forum Support / SB Dev
  • Posts: 3115
    • ScriptBasic Open Source Project
Re: ScriptBasic Windows 64 Bit
« Reply #29 on: August 26, 2021, 10:07:46 pm »
I changed the Makefile a bit to get rid of the 32 bit references. Compiled with no errors. It still won't load the extension module.

Code: Bash
  1. all : pui.a pui.dll
  2.  
  3. pui.a : bin\mod\obj\pui\s_interface.o
  4.         ar -r ..\..\bin\mod\lib\pui.a ..\..\bin\mod\obj\pui\s_interface.o C:\iup64\libiup.a C:\iup64\libiupcd.a C:\iup64\libiupcontrols.a C:\iup64\libiupimglib.a C:\iup64\libfreetype6.a
  5.  
  6. pui.dll : bin\mod\obj\pui\interface.o
  7.         gcc -Wno-write-strings -pipe -shared -w -s -O2 -m64 -Wl,--add-stdcall-alias,--output-def,"..\..\bin\mod\dll\pui_imp.def",--out-implib,"..\..\bin\mod\dll\pui_imp.a" -o ..\..\bin\mod\dll\pui.dll ..\..\bin\mod\obj\pui\interface.o -LC:\iup64 -IC:\iup64\include -liup -liupcd -liupcontrols -liupimglib -lfreetype6
  8.  
  9. bin\mod\obj\pui\interface.o : interface.c
  10.         gcc -w -D_WIN32 -m64 -c -LC:\iup64 -IC:\iup64\include -o ..\..\bin\mod\obj\pui\interface.o interface.c
  11.  
  12. bin\mod\obj\pui\s_interface.o : interface.c
  13.         gcc -w -D_WIN32 -m64 -c -LC:\iup64 -IC:\iup64\include -o ..\..\bin\mod\obj\pui\s_interface.o interface.c
  14.  

I thought I would try to compile one of IUP's examples as an .exe executable. It worked great using the IUP library I'm trying to get working with SB.

Code: C
  1. // gcc -m64 matrixlist.c -o matlst64.exe -LC:\iup64 -IC:\iup64\include -liup -liupcontrols -lcd
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. #include <iup.h>
  8. #include <iupcontrols.h>
  9. #include <cd.h>
  10.  
  11.  
  12. static int imagevaluechanged_cb(Ihandle *self, int item, int state)
  13. {
  14.         printf("imagevaluechanged_cb(item=%d, state=%d)\n", item, state);
  15.         return IUP_DEFAULT;
  16. }
  17.  
  18. static int listclick_cb(Ihandle *self, int lin, int col, char *status)
  19. {
  20.   char* value = IupGetAttributeId(self, "", lin);
  21.   if (!value) value = "NULL";
  22.   printf("listclick_cb(%d, %d)\n", lin, col);
  23.   printf("  VALUE%d:%d = %s\n", lin, col, value);
  24.   return IUP_DEFAULT;
  25. }
  26.  
  27. static int listaction_cb(Ihandle *self, int item, int state)
  28. {
  29.   printf("listaction_cb(item=%d, state=%d)\n", item, state);
  30.   return IUP_DEFAULT;
  31. }
  32.  
  33. int main(int argc, char **argv)
  34. {
  35.   Ihandle *dlg, *mlist;
  36.   IupOpen(&argc, &argv);      
  37.   IupControlsOpen();
  38.  
  39.   mlist = IupMatrixList();
  40.   IupSetInt(mlist, "COUNT", 10);
  41.   IupSetInt(mlist, "VISIBLELINES", 9);
  42.     IupSetAttribute(mlist, "COLUMNORDER", "LABEL:COLOR:IMAGE");
  43. //  IupSetAttribute(mlist, "COLUMNORDER", "LABEL:COLOR");
  44. //  IupSetAttribute(mlist, "COLUMNORDER", "LABEL");
  45. //  IupSetAttribute(mlist, "ACTIVE", "NO");
  46. //  IupSetAttribute(mlist, "FOCUSCOLOR", "BGCOLOR");
  47.   IupSetAttribute(mlist, "SHOWDELETE", "Yes");
  48. //  IupSetAttribute(mlist, "EXPAND", "Yes");
  49.  
  50.   IupSetAttribute(mlist, "EDITABLE", "Yes");
  51.   IupSetCallback(mlist,"LISTCLICK_CB",(Icallback)listclick_cb);
  52.   IupSetCallback(mlist,"LISTACTION_CB",(Icallback)listaction_cb);
  53.   IupSetCallback(mlist, "IMAGEVALUECHANGED_CB", (Icallback)imagevaluechanged_cb);
  54.  
  55.   /* Bluish style */
  56.   if (1)
  57.   {
  58.     IupSetAttribute(mlist, "TITLE", "Test");
  59.     IupSetAttribute(mlist, "BGCOLOR", "220 230 240");
  60.     IupSetAttribute(mlist, "FRAMECOLOR", "120 140 160");
  61.     IupSetAttribute(mlist, "ITEMBGCOLOR0", "120 140 160");
  62.     IupSetAttribute(mlist, "ITEMFGCOLOR0", "255 255 255");
  63.   }
  64.  
  65.   IupSetAttribute(mlist, "1", "AAA");
  66.   IupSetAttribute(mlist, "2", "BBB");
  67.   IupSetAttribute(mlist, "3", "CCC");
  68.   IupSetAttribute(mlist, "4", "DDD");
  69.   IupSetAttribute(mlist, "5", "EEE");
  70.   IupSetAttribute(mlist, "6", "FFF");
  71.   IupSetAttribute(mlist, "7", "GGG");
  72.   IupSetAttribute(mlist, "8", "HHH");
  73.   IupSetAttribute(mlist, "9", "III");
  74.   IupSetAttribute(mlist, "10","JJJ");
  75.  
  76.   IupSetAttribute(mlist, "COLOR1", "255 0 0");
  77.   IupSetAttribute(mlist, "COLOR2", "255 255 0");
  78.   //IupSetAttribute(mlist, "COLOR3", "0 255 0");
  79.   IupSetAttribute(mlist, "COLOR4", "0 255 255");
  80.   IupSetAttribute(mlist, "COLOR5", "0 0 255");
  81.   IupSetAttribute(mlist, "COLOR6", "255 0 255");
  82.   IupSetAttribute(mlist, "COLOR7", "255 128 0");
  83.   IupSetAttribute(mlist, "COLOR8", "255 128 128");
  84.   IupSetAttribute(mlist, "COLOR9", "0 255 128");
  85.   IupSetAttribute(mlist, "COLOR10", "128 255 128");
  86.  
  87.   IupSetAttribute(mlist, "ITEMACTIVE3", "NO");
  88.   IupSetAttribute(mlist, "ITEMACTIVE7", "NO");
  89.   IupSetAttribute(mlist, "ITEMACTIVE8", "NO");
  90.  
  91.   IupSetAttribute(mlist, "IMAGEACTIVE9", "No");
  92.  
  93.   IupSetAttribute(mlist, "IMAGEVALUE1", "ON");
  94.   IupSetAttribute(mlist, "IMAGEVALUE2", "ON");
  95.   IupSetAttribute(mlist, "IMAGEVALUE3", "ON");
  96.  
  97.   dlg = IupDialog(IupVbox(mlist, NULL));
  98.   IupSetAttribute(dlg, "TITLE", "IupMatrixList");
  99.   IupSetAttribute(dlg, "MARGIN", "10x10");
  100. //  IupSetAttribute(dlg, "FONT", "Helvetica, 24");
  101.   IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  102.  
  103.   IupSetAttribute(mlist, "APPENDITEM","KKK");
  104.  
  105.   IupMainLoop();
  106.   IupClose();  
  107.   return EXIT_SUCCESS;
  108. }
  109.  

« Last Edit: August 26, 2021, 11:00:42 pm by John »