AllBASIC

BASIC Developer & Support Resources => Scripting Languages => Topic started by: John on August 19, 2021, 10:22:51 pm

Title: ScriptBasic Windows 64 Bit
Post by: John on August 19, 2021, 10:22:51 pm
That's great AIR. Nice to have a 64 bit SB on Windows again. Works here.

Do you have a 64 bit build you can share and what did you use to build it?

I took a peek at the scriba.exe you sent and I was surprised it contained exports

Does this mean I don't need libscriba.dll for the SBT extension module?

Code: Bash
  1. scriba_BuildCode, 1, 0xfcaa
  2. scriba_Call, 2, 0x10ca9
  3. scriba_CallArg, 3, 0x10cf2
  4. scriba_CallArgEx, 4, 0x1168e
  5. scriba_destroy, 65, 0xe3e9
  6. scriba_DestroySbArgs, 5, 0x1109c
  7. scriba_DestroySbData, 6, 0xe7bd
  8. scriba_DoLexicalAnalysis, 7, 0xf726
  9. scriba_DoSyntaxAnalysis, 8, 0xfa1a
  10. scriba_FinishStaticModules, 9, 0x123f5
  11. scriba_GetCacheFileName, 10, 0xfe00
  12. scriba_GetConfigFileName, 11, 0xec0a
  13. scriba_GetVariable, 12, 0x11dee
  14. scriba_GetVariableType, 13, 0x11d39
  15. scriba_InheritBinaryProgram, 14, 0xf216
  16. scriba_InheritConfiguration, 15, 0xec48
  17. scriba_InheritExecuteObject, 16, 0xee1f
  18. scriba_InheritModuleInterface, 17, 0xedf2
  19. scriba_InitModuleInterface, 18, 0xec8d
  20. scriba_InitSbData, 19, 0xe486
  21. scriba_InitStaticModules, 20, 0x12376
  22. scriba_IsFileBinaryFormat, 21, 0xfdde
  23. scriba_LoadBinaryProgram, 22, 0xf1f0
  24. scriba_LoadBinaryProgramWithOffset, 23, 0xf0e3
  25. scriba_LoadConfiguration, 24, 0xeb72
  26. scriba_LoadInternalPreprocessor, 25, 0xf313
  27. scriba_LoadProgramString, 26, 0x1045e
  28. scriba_LoadSourceProgram, 27, 0x102c9
  29. scriba_LookupFunctionByName, 28, 0x11cc8
  30. scriba_LookupVariableByName, 29, 0x11cf5
  31. scriba_new, 66, 0xe250
  32. scriba_NewSbArgs, 30, 0x1111b
  33. scriba_NewSbBytes, 31, 0xe6bb
  34. scriba_NewSbData, 32, 0xe441
  35. scriba_NewSbDouble, 33, 0xe546
  36. scriba_NewSbLong, 34, 0xe501
  37. scriba_NewSbString, 35, 0xe5c9
  38. scriba_NewSbUndef, 36, 0xe591
  39. scriba_NoRun, 37, 0x10bce
  40. scriba_PurgeBuilderMemory, 38, 0xe92e
  41. scriba_PurgeExecuteMemory, 39, 0xea04
  42. scriba_PurgeLexerMemory, 40, 0xe86c
  43. scriba_PurgePreprocessorMemory, 41, 0xe9a5
  44. scriba_PurgeReaderMemory, 42, 0xe809
  45. scriba_PurgeSyntaxerMemory, 43, 0xe8cf
  46. scriba_ReadSource, 44, 0xf44f
  47. scriba_ResetVariables, 45, 0x10c5a
  48. scriba_Run, 46, 0x10aa1
  49. scriba_RunExternalPreprocessor, 47, 0x10111
  50. scriba_SaveCacheFile, 49, 0x100c1
  51. scriba_SaveCCode, 48, 0x10262
  52. scriba_SaveCode, 50, 0x10235
  53. scriba_SaveECode, 51, 0x10290
  54. scriba_SetCgiFlag, 52, 0xef45
  55. scriba_SetEmbedPointer, 53, 0xf061
  56. scriba_SetEnvironment, 54, 0xf0a2
  57. scriba_SetFileName, 55, 0xead8
  58. scriba_SetProcessSbObject, 56, 0xee45
  59. scriba_SetReportFunction, 57, 0xef63
  60. scriba_SetReportPointer, 58, 0xefa1
  61. scriba_SetStdin, 59, 0xefdf
  62. scriba_SetStdout, 60, 0xf020
  63. scriba_SetVariable, 61, 0x12032
  64. scriba_ShutdownMtModules, 62, 0xeeba
  65. scriba_UndefSbData, 63, 0xe4a8
  66. scriba_UseCacheFile, 64, 0xffb4
  67.  



Title: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 12:31:39 am
AIR,

I started a new thread for the ScriptBasic Windows 64 effort. It seems I did compile a 64 bit version of ScriptBasic which has a SBC and SBW version. I couldn't get a 64 bit cURL to compile so your contribution filled that hole. Here is a GMP example in 64 bit.

ODBC 64 bit is the next challenge.

Code: Script BASIC
  1. DECLARE SUB BI_ADD  ALIAS  "add"     LIB "gmp10"
  2. DECLARE SUB BI_SUB  ALIAS  "sub"     LIB "gmp10"
  3. DECLARE SUB BI_MUL  ALIAS  "mul"     LIB "gmp10"
  4. DECLARE SUB BI_DIV  ALIAS  "divide"  LIB "gmp10"
  5.  
  6. a = "1234567890"
  7. b = "0987654321"
  8.  
  9.  
  10. PRINT "ADD: ", BI_ADD(a,b),"\n"
  11. PRINT "SUB: ", BI_SUB(a,b),"\n"
  12. PRINT "MUL: ", BI_MUL(a,b),"\n"
  13. PRINT "DIV: ", BI_DIV(a,2),"\n\n"
  14.  
  15. PRINT "MAXINT: ",MAXINT,"\n"
  16.  


C:\ScriptBasic\examples>sbc gmpmath.sb
ADD: 2222222211
SUB: 246913569
MUL: 1219326311126352690
DIV: 617283945

MAXINT: 2147483647

C:\ScriptBasic\examples>

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 12:49:35 am
This is the SBT (thread extension module) example in 64 bit.

Code: Script BASIC
  1. ' SBT 64 bit Demo
  2.  
  3. IMPORT sbt.sbi
  4.  
  5. sb_code = """
  6. FUNCTION prtvars(a, b, c)
  7.  PRINT a,"\\n"
  8.  PRINT FORMAT("%g\\n", b)
  9.  PRINT c,"\\n"
  10.  prtvars = "Function Return"
  11. END FUNCTION
  12.  
  13. a = 0
  14. b = 0
  15. c = ""
  16. """
  17.  
  18. sb = SB_New()
  19. SB_Configure sb, "C:/Windows/SCRIBA.INI"
  20. SB_Loadstr sb, sb_code
  21. SB_NoRun sb
  22. ' Call function before running script
  23. funcrtn = SB_CallSubArgs(sb,"main::prtvars", 123, 1.23, "One, Two, Three")
  24. PRINT funcrtn,"\n"
  25. ' Run script initializing globals
  26. SB_Run sb, ""
  27. ' Assign variables values
  28. SB_SetInt sb, "main::a", 321
  29. SB_SetDbl sb, "main::b", 32.1
  30. SB_SetStr sb, "main::c", "Three,Two,One" & CHR(0)
  31. ' Call function again with variables assigned in the previous step
  32. SB_CallSubArgs sb, "main::prtvars", _
  33.           SB_GetVar(sb, "main::a"), _
  34.           SB_GetVar(sb, "main::b"), _
  35.           SB_GetVar(sb, "main::c")
  36. SB_Destroy sb
  37.  


C:\ScriptBasic\examples>sbc sbt_demo.sb
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One

C:\ScriptBasic\examples>

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 12:56:48 am
SQLite 64 bit.

Code: Script BASIC
  1. ' SQLite CREATE / INSERT / SELECT
  2.  
  3. IMPORT sqlite.sbi
  4.  
  5. db = sqlite::open("sqlite_demo.db")
  6.  
  7. sqlite::execute(db,"create table demo (someval integer, sometxt text);")
  8. sqlite::execute(db,"insert into demo values (123,'hello');")
  9. sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")
  10. sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")
  11.  
  12.  
  13. stmt = sqlite::query(db,"SELECT * FROM demo")
  14.  
  15. WHILE sqlite::row(stmt) = sqlite::SQLITE3_ROW
  16.   IF sqlite::fetchhash(stmt, column) THEN
  17.     PRINT column{"someval"},"\t-\t",column{"sometxt"},"\n"
  18.   END IF
  19. WEND
  20.  
  21. sqlite::close(db)
  22.  


C:\ScriptBasic\examples>sbc sqlite_demo.sb
123     -       hello
234     -       cruel
345     -       world

C:\ScriptBasic\examples>

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 01:04:22 am
Mini XML

Code: Script BASIC
  1. include mxml.sbi
  2.  
  3. filename = "mxml_demo.xml"
  4.  
  5. doc = mxml::LoadDoc(filename)
  6.  
  7. node =  mxml::GetNode(doc,"/stufflist/stuff_test")
  8. if node then print "Test1: ", mxml::GetNodeValue(node),"\n"
  9.  
  10. node =  mxml::GetNode(doc,"/stufflist/stuff_test2")
  11. if (node) then print "Test2: ", mxml::GetNodeValue(node),"\n\n"
  12.  
  13.  
  14. node = mxml::GetNode(doc,"/stufflist/stuff_test3/painting/img")
  15. if node then
  16.         print "Image: ", mxml::GetProperty(node,"src"), "\n"
  17.         print "Alt Image: ", mxml::GetProperty(node,"alt"), "\n\n"
  18. endif
  19.  
  20.  
  21. node = mxml::GetNode(doc,"/stufflist/books")
  22. child = mxml::GetChild(node)
  23.  
  24. while child
  25.         node = mxml::GetNode(child,"id")
  26.         if node then print "ID = ", mxml::GetNodeValue(node),"\n"
  27.         node = mxml::GetNode(child,"name")
  28.         if node then print "Name = ", mxml::GetNodeValue(node),"\n"
  29.  
  30.         child = mxml::GetNext(child)
  31. wend
  32.  
  33.  
  34. if doc then mxml::FreeDoc(doc)
  35.  


C:\ScriptBasic\examples>sbc mxml_demo.sb
Test1: This is a test!
Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael


C:\ScriptBasic\examples>


JSON

Code: Script BASIC
  1. ' SB JSON Create Entries
  2.  
  3. import json.sbi
  4.  
  5. root = json::New()
  6. json::SetText(root,"client1.name","Joe Blow")
  7. json::SetNum(root,"client1.age", 56)
  8. json::SetText(root,"client1.address.city","Tarrytown")
  9. json::SetText(root,"client1.address.state","NY")
  10. json::SetText(root,"client1.address.zip","10891")
  11.  
  12. json::SetText(root,"client2.name","John Smith")
  13. json::SetNum(root,"client2.age",86)
  14. json::SetText(root,"client2.address.city","Cupertino")
  15. json::SetText(root,"client2.address.state","CA")
  16. json::SetText(root,"client2.address.zip","N/A")
  17. json::Save("root.json")
  18.  

Code: Script BASIC
  1. ' SB READ IN CREATED JSON
  2.  
  3. import json.sbi
  4.  
  5. jObject = json::loadfile("root.json")
  6. for i = 0 to json::count(jObject)-1
  7.     obj = json::object(jObject,i)
  8.     print string(40,"-"),"\n"
  9.     print json::Get(obj,"name"),"\n"
  10.     print json::Get(obj,"age"),"\n"
  11.     print json::Get(obj,"address.city"),"\n"
  12.     print json::Get(obj,"address.state"),"\n"
  13.     print json::Get(obj,"address.zip"),"\n"
  14. next
  15. print string(40,"-"),"\n"
  16.  

root.json

Code: Text
  1. {
  2.     "client1": {
  3.         "name": "Joe Blow",
  4.         "age": 56,
  5.         "address": {
  6.             "city": "Tarrytown",
  7.             "state": "NY",
  8.             "zip": "10891"
  9.         }
  10.     },
  11.     "client2": {
  12.         "name": "John Smith",
  13.         "age": 86,
  14.         "address": {
  15.             "city": "Cupertino",
  16.             "state": "CA",
  17.             "zip": "N\/A"
  18.         }
  19.     }
  20. }
  21.  


C:\ScriptBasic\examples>sbc parse.sb
----------------------------------------
Joe Blow
56
Tarrytown
NY
10891
----------------------------------------
John Smith
86
Cupertino
CA
N/A
----------------------------------------

C:\ScriptBasic\examples>

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 01:09:18 am
AIR's cURL for 64 bit ScriptBasic.

Code: Script BASIC
  1. ' AIR RSS Challenge
  2.  
  3. IMPORT curl.sbi
  4.  
  5. ch = curl::init()
  6. curl::option(ch, "URL", "http://channel9.msdn.com/Events/MIX/MIX11/RSS/mp4high")
  7. curl::option(ch, "FOLLOWLOCATION")
  8. rss = curl::perform(ch)
  9. curl::finish(ch)
  10.  
  11. SPLITA rss BY "</item>" TO item
  12. FOR x = 0 TO UBOUND(item)
  13.   IF item[x] LIKE "*<title>*</title>*[CDATA[<p>*</p>*<pubDate>*</pub*<dc:creator>*</dc:*<enclosure url=\"*\" length*duration=\"*\"*" THEN
  14.     PRINT STRING(20,"-"), "\n"
  15.     PRINT "Title: ", JOKER(2), "\n"
  16.     PRINT "Presenter: ",JOKER(8), "\n"
  17.     PRINT "Date: ", JOKER(6), "\n"
  18.     PRINT "Description: ", JOKER(4), "\n"
  19.     PRINT "Video Link: ", JOKER(10), "\n"
  20.     PRINT "Duration: ", FORMATDATE("0H:0m:0s", JOKER(12)), "\n"
  21.   END IF
  22. NEXT
  23.  


--------------------
Title: Riding the Geolocation Wave
Presenter: Tatham Oddie
Date: Tue, 15 Mar 2011 20:26:00 GMT
Description: It&rsquo;s pretty obvious by now that geolocation is a heavy player in the next wave of applications and APIs. Now is the time to learn how to take advantage of this information and add context to your own applications. In this session we&rsquo;ll look at geolocation at every layer of the stack &ndash; from open protocols to operating system APIs, from the browser to Windows Phone 7. Building a compelling geo-enabled experience takes more than simple coordinates. In this session we will introduce the basics of determining a user&rsquo;s location and then delve into how to make geo data a useful addition to your application instead of a bolt-on &ldquo;me too&rdquo;.
Video Link: http://video.ch9.ms/ch9/7ce8/f849553d-644e-4dad-8deb-9ea700dd7ce8/MIX11EXT04_high_ch9.mp4
Duration: 00:47:52
--------------------
Title: Flickr API: Tap Into Billions of Photos for Windows Phone 7
Presenter: Markus Spiering
Date: Tue, 15 Mar 2011 20:26:00 GMT
Description: Do you want your app to integrate with one of the world&rsquo;s leading photosharing site? The Flickr for Windows Phone 7 app is a full featured mobile application that is pushing the boundaries of UX design and is 100% built on Flickr's API methods that are available for developers. This talk will introduce the mobile app, highlight some of the complex design decisions, and provide insights into the Flickr API methods. Attendees will learn how to enrich their applications using Flickr's rich content via the Flickr APIs.
Video Link: http://video.ch9.ms/ch9/7BAE/1F7A8CCB-5580-47BF-9371-9EA700DD7BAE/MIX11EXT01_high_ch9.mp4
Duration: 00:50:32
--------------------
Title: Fonts, Form and Function: A Primer on Digital Typography
Presenter: Robby Ingebretsen
Date: Tue, 15 Mar 2011 20:26:00 GMT
Description: Typography in digital experiences is unavoidable, and for years it was a fight we mostly lost. Today, however, technology is on our side! High resolution screens, an expanding library of open fonts and new flexibility in nearly every UI technology have made digital typography more fun and more interesting than ever. We'll cover all aspects of working with digital type: everything from choosing complimentary typefaces to licensing, rendering and a system for layout and sizing. We all love type. Come to this talk to learn why!
Video Link: http://video.ch9.ms/ch9/7bc8/133b3b99-1949-4ef4-a27c-9ec6010c7bc8/MIX11EXT02_high_ch9.mp4
Duration: 01:03:27

Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 20, 2021, 01:32:54 pm
where is your 32bit SOURCE tree?  Sandbox has some old stuff
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 03:01:15 pm
AIR,

I put a zip of the SB Win32 source on the server. I sent you a forum PM with the link.

ODBC has been enhanced. (4096 columns size & FetchSchema)

I built the SB Win 64 with this same source using TDM-CGG-64.

John
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 20, 2021, 05:51:49 pm
Your modules were still configured to compile to 32 bit.  I replied to your PM.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 05:56:19 pm
The 64 bit compile used a copy of your make I modified using -m64. The source build I sent you was configured to produce 32 bit.

Is the ODBC for 64 bit going to need special handling? This is a critical extension module for me.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 07:16:23 pm
Good News!

The ODBC extension for 64 bit compiled with TDM-GCC-64. I haven't tried it yet but at least it built.

Code: Bash
  1. C:\sbgcc\sbw64_src\extensions\odbc>mingw32-make -B -f Makefile
  2. gcc -w -D_WIN32 -m64 -c -o ..\..\bin\mod\obj\odbc\s_interface.o interface.c
  3. ar -r ..\..\bin\mod\lib\odbc.a ..\..\bin\mod\obj\odbc\s_interface.o C:\TDM-GCC-32\lib\libodbc32.a C:\TDM-GCC-32\lib\libodbccp32.a
  4. ar: creating ..\..\bin\mod\lib\odbc.a
  5. gcc -w -D_WIN32 -m64 -c -o ..\..\bin\mod\obj\odbc\interface.o interface.c
  6. gcc -Wno-write-strings -D_WIN32 -static-libgcc -pipe -shared -w -s -O2 -m64 -Wl,--add-stdcall-alias,--output-def,"..\..\bin\mod\dll\odbc_imp.def",--out-implib,"..\..\bin\mod\dll\odbc_imp.a" -o ..\..\bin\mod\dll\odbc.dll ..\..\bin\mod\obj\odbc\interface.o -lodbc32 -lodbccp32
  7.  
  8. C:\sbgcc\sbw64_src\extensions\odbc>
  9.  

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 07:33:20 pm
I just rebuilt it using the Makefile you sent me. Compiled fine. I'll give it a try shortly.

It connects to the Postgres SQL server using the 64 bit ODBC driver but fails on the query.


I needed to use the unicode version of the Postgres SQL ODBC driver.  The data is being truncated.

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
    MT0 -      Man Technologies
    BA7 -     BA
    NG6 -      Bin Hindi Group
    184 -     trong Atl St Univ Biol
    999 -     trong Atl St Univ
    TP8 -     American Business Review
    060 -      Arundel CC Biol
    476 -     linik RWTH Aachen
    EN7 -     ersitatsklinikum Aachen
    NA8 -     rto Aduna

C:\ScriptBasic\examples>


The VB6 ODBC viewer I have works with the 32 bit Postgres SQl ODBC unicode driver.

The Postgres SQL 32 bit Unicode driver works fine with SB 32.


C:\ScriptBasic\examples>sbc psql_32U.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>

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 09:46:01 pm
I tried MS SQL Server using the 32/64 bit native client ODBC driver. I couldn't connect to the DB with SB 64 ODBC but using the same driver under SB 32 bit works fine.

Code: Script BASIC
  1. IMPORT odbc.sbi
  2.  
  3. dbh = odbc::RealConnect("MSSQL","","")
  4. SQL = "SELECT * FROM johnspikowski.AR_Customer"
  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 mssql32.sb
ABF - American Business Futures
ABS - ABS - Sage cloud for invoices
AVNET - Avnet Processing Corp
BRESLIN - Breslin Parts Supply
HILLSB - Hillsboro Service Center
INACTIV - Inactive Customer **INACTIVE**
INTMEX - Int. Cust with Mexican Address Name expanded to 50
MAVRK - Maverick Papers
RSSUPPL - R & S Supply Corp.
SHEPARD - Shepard Motorworks
ALLENAP - Allen's Appliance Repair
AMERCON - American Concrete Service
ATOZ - A To Z Carpet Supply
AUTOCR - Autocraft Accessories
BAYPYRO - Bay Pyrotronics Corp.
CAPRI - Capri Sailing Ships
CUSTOM - Custom Craft Products
GREALAR - Greater Alarm Company
JELLCO - Jellco Packing
ORANGE - Orange Door & Window Co.

C:\ScriptBasic\examples>


My guess at this point is the SB 64 bit ODBC extension module isn't working correctly.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 20, 2021, 09:59:37 pm
Creating a new MS SQL 64 bit ODBC definition allow me to connect to the DB but Query caused an extension module failure.

Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 20, 2021, 10:16:50 pm
Don't you need a 64bit MySQL ODBC connector driver installed and configured?
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR 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.

Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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)
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.  
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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!

Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 21, 2021, 09:32:53 pm
The standard 64bit SQL Server driver that comes with Windows 10.


Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR 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.....
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.



Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.  
Title: Re: ScriptBasic Windows 64 Bit
Post by: John 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.  

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 06:00:22 pm
Hi AIR,

I hope you are still interested in seeing a 64 bit build of SB.

I have tried just about everything I could think of to get the pui.dll (IUP extension module) to load. If you have a spare moment can you try it on your end? At least we know IUP 64 bit libraries work with TDM-GCC-64. All my Makefile seem to compile without error. Getting the module to load in SB is the problem.

I have attached my iup64 directory which may save you some time from downloading IUP.

 
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 27, 2021, 06:43:51 pm
Your problem is with sbc/sbw.

The 64bit scriba I built previously works with the statically built pui.dll I created (no need for all the silly IUP dll's, another reason why I don't use it).

You're going to have to figure out what you changed that is causing the issue.

Attached is the 64bit scriba I built and tested with, and the pui.dll I built.


Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 06:51:36 pm
We are thinking alike. Before reading your post I tried a really old SB Windows 64 build and the PUI extension module worked.

I'll give your build a try.

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 06:58:59 pm
Your scriba.exe and pui.dll worked. Only problem is there is no Windows style / theme support like sbc.exe and sbw.exe provided.

Is it possible your sb64gui.o was causing the issue not loading? I believe I used the IUP resource for the 32 bit sbgui.o.

Can you post your pui Makefile so I can generate a static linked IUP and not have to include IUP DLLs with the distribution?

Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 27, 2021, 07:55:05 pm
Attached.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 07:57:56 pm
THANK YOU!

We now have what I call a core distribution of SB Windows 64. I don't see a need for MySQL as that is mostly used on Linux. The cURL, ODBC and IUP modules were key to getting people to try / use the BASIC. My next task is to get true callbacks working with IUP. My attempt at callbacks works but very limited and slow.

Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 08:10:29 pm
That was it. I recompiled my sbc.exe and sbw.exe with your new sb64gui.o.

I'm assuming you sent in your PUI.zip everything that is needed to static link IUP? I don't need to download the static library from SourceForge?
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 27, 2021, 08:48:41 pm
The static libs you get from sourceforge do NOT allow you to build a dll of any kind.  They are for static linking when creating EXE files.


Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 09:01:09 pm
I just replaced my PUI extension module folder with yours. I recompiled the module and it works.

Quote from: AIR
The static libs you get from sourceforge do NOT allow you to build a dll of any kind.  They are for static linking when creating EXE files.

Good to know. Thanks for clarifying that for me.

Code: Bash
  1. C:\sbgcc\sbw64_src\extensions\pui>mingw32-make -B -f Makefile
  2. gcc -w -D_WIN32 -m64 -c -I.\IUP-330\include -o ..\..\bin\mod\obj\pui\s_interface.o interface.c
  3. ar -r ..\..\bin\mod\lib\pui.a ..\..\bin\mod\obj\pui\s_interface.o
  4. gcc -w -D_WIN32 -m64 -c -I.\IUP-330\include -o ..\..\bin\mod\obj\pui\interface.o interface.c
  5. gcc  -shared  -s -O2 -Wl,--output-def,"..\..\bin\mod\dll\pui_imp.def",--out-implib,"..\..\bin\mod\dll\pui_imp.a",--export-all-symbols,--enable-auto-image-base  -o ..\..\bin\mod\dll\pui.dll ..\..\bin\mod\obj\pui\interface.o -L.\IUP-330 -I.\IUP-330\include     -liup -liupcontrols -liupimglib   -liupcd -lcd -lfreetype6 -lz    -lmingw32 -lws2_32 -ladvapi32 -lgdi32 -lcomctl32 -lcomdlg32 -luuid -lole32
  6.  
  7. C:\sbgcc\sbw64_src\extensions\pui>
  8.  

Dave Zimmer with his COM extension had callbacks working from his DLL so I know it can be done and I have an example to work from.

I noticed the -lole32 reference in the Makefile. I thought COM/OLE is only supported under 32 bit.
Title: Re: ScriptBasic Windows 64 Bit
Post by: AIR on August 27, 2021, 09:20:12 pm
I noticed the -lole32 reference in the Makefile. I thought COM/OLE is only supported under 32 bit.

It depends on the COM interface you're interacting with.  If a system has both 64 and 32 bit COM interfaces for a given task, 64bit Windows will try using the 64bit interface by default.  If all you have is 32 bit, it will try to use that.
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 27, 2021, 09:29:18 pm
Made my day. I thought COM was lost going to 64 bit. .NET is your new friend

32 and 64 bit COM Servers (https://mariusbancila.ro/blog/2010/11/04/32-bit-and-64-bit-com-servers/)
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 28, 2021, 05:29:50 pm
I just tried the dyc extension module and SB said the module can't be loaded. If I remember correctly DYC uses ASM. Is this a Windows 32 bit only extension?
Title: Re: ScriptBasic Windows 64 Bit
Post by: John on August 31, 2021, 12:13:28 am
AIR,

I can't seem to get the 64 bit version SBHTTPD to connect. It seems to load fine but when I try run a script it says the server can't be found. The 32 bit version works fine.