Recent Posts

Pages: [1] 2 3 ... 10
1
Open Forum / Mike
« Last post by John on January 22, 2020, 12:58:28 PM »
Quote from: Patrice@O2


Mike Lobanovsky

 on: January 22, 2020, 08:00:41 AM

I am very sorry to inform you that Mike's health is in a very critical state.
He has been put in major sedation.
His doctor does not have a positive forecast. 

Nothing else to do than hope and pray for now...
2
Scripting Languages / Re: Scriptbasic Build Linux
« Last post by John on January 19, 2020, 07:29:39 PM »
I decided to move to MySQL as SQLite isn't robust enough for my requirements. If you find time to look at the column duping issue that would be great.
3
Scripting Languages / Re: Scriptbasic Build Linux
« Last post by John on January 19, 2020, 05:42:07 AM »
AIR,

There seems to be a problem with your SQLite SB extension module. The column data is being duplicated in columns that should be null. If I do the select in the SQLite3 CLI, it displays the data correctly.
4
Scripting Languages / Re: Script BASIC for Java
« Last post by John on January 18, 2020, 11:35:07 AM »
Quote from: Peter Verhas
With the pull req made by Petr Pytelka the version 2.1.0 of jScriptBasic is released. It is a simple embeddable BASIC interpreter written in Java that you can use in applications to let users write simple scripts. This rel features multiple commands on a single line. Thanks Petr

Multiple statements per line is a major direction change IMHO.
5
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on January 08, 2020, 06:50:36 AM »
AIR,

A response from Antonio.

Quote
Hi,

  I just committed some of the changes to tecmake.mak in IUP SVN.

Best,

Scuri

BTW, other changes should be set on the user environment. Like:

USE_LUA53=YES
USE_PKGCONFIG=YES
USE_GTK3=YES
LUA51=$(TECTOOLS_HOME)/lua51
LUA_SFX=51



6
Nim / Re: winim
« Last post by John on January 08, 2020, 06:23:10 AM »
I have been playing with XML parsers and have come to the conclusion that ScriptBasic SPLITA and LIKE blows away anything I've tried. QuickBooks may just have a new scripting option. QBScript 😎
7
Nim / Re: winim
« Last post by John on January 04, 2020, 05:12:26 PM »
One of my concerns rebuilding my toolbox with Nim was COM/OLE (CallbyName) support. I'm happy to say that concern is behind me. I do a lot of interface work with QuickBooks Enterprise which uses a COM SDK as their interface. Here is an example of a ScriptBasic and Nim script to return the CoA. (Chart of Accounts)

Code: Script BASIC
  1. IMPORT COM.sbi
  2.  
  3. oqbXMLRP = COM::CREATE(:SET, "QBFC13.QBSessionManager.1")
  4.  
  5. COM::CBN(oqbXMLRP, "OpenConnection", :CALL, "", "ScriptBasic")
  6. COM::CBN(oqbXMLRP, "BeginSession", :CALL, "", 2)
  7.  
  8. xml_request = """
  9. <?qbxml version="13.0"?>
  10. <QBXML>
  11.   <QBXMLMsgsRq onError="stopOnError">
  12.     <AccountQueryRq>
  13.     </AccountQueryRq>
  14.   </QBXMLMsgsRq>
  15. </QBXML>
  16. """
  17.  
  18. oResponse = COM::CBN(oqbXMLRP, "DoRequestsFromXMLString", :CALL, xml_request)
  19. xml_str = COM::CBN(oResponse, "ToXMLString", :CALL)
  20.  
  21. PRINT xml_str,"\n"
  22.  
  23. COM::CBN(oqbXMLRP, "EndSession", :CALL)
  24. COM::CBN(oqbXMLRP, "CloseConnection", :CALL)
  25. COM::RELEASE(oResponse)
  26. COM::RELEASE(oqbXMLRP)
  27.  

Nim
Code: Text
  1. import winim.com
  2.  
  3. comScript:
  4.  
  5.   var xml_request = """
  6.   <?qbxml version="13.0"?>
  7.   <QBXML>
  8.     <QBXMLMsgsRq onError="stopOnError">
  9.       <AccountQueryRq>
  10.       </AccountQueryRq>
  11.     </QBXMLMsgsRq>
  12.   </QBXML>
  13.   """
  14.   var qbobj = CreateObject("QBFC13.QBSessionManager.1")
  15.  
  16.   qbobj.OpenConnection("", "Nim")
  17.   qbobj.BeginSession("", 2)
  18.  
  19.   var oResponse = qbobj.DoRequestsFromXMLString(xml_request)
  20.   var xml_str = oResponse.ToXMLString()  
  21.    
  22.   echo xml_str
  23.  
  24.   qbobj.EndSession()
  25.   qbobj.CloseConnection()
  26.  
  27.   COM_FullRelease()
  28.  


Attached is the response from this request using a QB demo company.
8
Nim / Re: winim
« Last post by John on January 04, 2020, 12:35:42 PM »
I was able to test the COM functionality of the winim library unsing Excel as my COM object.

Code: Text
  1. import strutils
  2. import winim.com
  3.  
  4. comScript:
  5.   var obj = CreateObject("Excel.Application")
  6.   obj.visible = true
  7.   obj.workbooks.add()
  8.  
  9.   var
  10.     s1 = "the quick fox jumps over the lazy brown dog".split(" ")
  11.     s2 = @[@[1, 2], @[3, 4, 5, 6, 7], @[8, 9, 10, 11], @[12], @[13, 14, 15]]
  12.  
  13.   obj.activeSheet.range("A1:E6").clear()
  14.   obj.activeSheet.range("A1:I1") = s1 # this convert seq to 1D safearray
  15.   obj.activeSheet.range("A2:E6") = s2 # this convert seq to 2D safearray
  16.  
  17.   # obj.activeSheet.saveAs("jrs.xls")
  18.   # obj.activeSheet.close(0)
  19.  
  20.   COM_FullRelease()
  21.  

9
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on January 04, 2020, 12:32:58 PM »
Will you be posting this to Raspberry BASIC with some screenshots?
10
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by AIR on January 04, 2020, 12:16:15 PM »
Updated C submission.

The libc 'crypt' function is configured to use a SHA-512 hashed password, which was generated using the default 5000 hash iterations.

Full source with arm64 binary, required png grahpic, sqlite3 database, and sql dump attached.

EDIT:  the password for both the 'guest' and 'admin' accounts is...'password'.

Code: C
  1. /* logon2.c
  2.  *
  3.  * version 1.4
  4.  *
  5.  * GUI Logon Screen Challenge Submission
  6.  * C version, using GTK3
  7.  *
  8.  * Written by Armando I. Rivera (AIR)
  9.  *
  10.  * Compile:  gcc logon2.c $(pkg-config --libs --cflags gtk+-3.0 sqlite3) -lcrypt -o logon2
  11. */
  12.  
  13. #define _GNU_SOURCE
  14. #include <gtk/gtk.h>
  15. #include <stdio.h>
  16. #include <crypt.h>
  17. #include <sqlite3.h>
  18.  
  19. GtkWidget *window, *layout, *image, *btnLogin, *chkBox;
  20. GtkWidget *lblUser, *lblPass, *txtUser, *txtPass,*err_label;
  21.  
  22. void chkBox_cb (GtkToggleButton *toggle_button, gpointer data) {
  23.       if (gtk_toggle_button_get_active (toggle_button)) {
  24.           g_object_set(data,"visibility",TRUE,NULL);
  25.       }else{
  26.           g_object_set(data,"visibility",FALSE,NULL);
  27.       }
  28. }
  29.  
  30. void txtPass_cb( GtkWidget *widget, gpointer data ) {
  31.     g_object_set(data,"label","",NULL);
  32. }
  33.  
  34. void txtUser_cb( GtkWidget *widget, gpointer data ) {
  35.     gtk_widget_grab_focus(data);
  36. }
  37.  
  38. int checkPassword(gchar *user, gchar *passwd) {
  39.     sqlite3_stmt *stmt = NULL;
  40.     sqlite3 *db;
  41.     gchar *zErrMsg = 0;
  42.     int rc;
  43.     gchar *sql,*stored_password=0,*stored_salt;
  44.     gchar *hashed_password;
  45.  
  46.     if (g_file_test("auth.db",G_FILE_TEST_EXISTS) == FALSE){
  47.       return(1);
  48.     }    
  49.  
  50.     if (rc = sqlite3_open("auth.db", &db)) {
  51.        return(2);
  52.     }
  53.     asprintf(&sql,"select username,password,salt from Users where username is '%s'",user);
  54.    
  55.     if (rc = sqlite3_prepare_v2(db, sql,-1,&stmt,0) != SQLITE_OK ) {
  56.         return(-1);
  57.     }
  58.  
  59.     free(sql);
  60.    
  61.     if (sqlite3_step(stmt) == SQLITE_ROW) {
  62.         stored_password = (gchar*)sqlite3_column_text(stmt,1);
  63.         stored_salt = (gchar*)sqlite3_column_text(stmt,2);
  64.         hashed_password= crypt(passwd,stored_salt);
  65.         return g_strcmp0 (hashed_password, stored_password);
  66.     }else{
  67.         return(3);
  68.     }
  69. }
  70.  
  71. void onClick( GtkWidget *widget, gpointer data ) {
  72.     gchar *user_name, *user_password;
  73.     int result;
  74.     g_object_get(txtUser,"text",&user_name,NULL);
  75.     g_object_get(txtPass,"text",&user_password,NULL);
  76.    
  77.     result = checkPassword(user_name, user_password);
  78.  
  79.     switch (result) {
  80.         case 0:
  81.             g_print("User '%s' now logged in!\n",user_name);
  82.             gtk_main_quit();
  83.             break;
  84.         case 1:
  85.             gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Database Not Found **</span>");
  86.             g_print("'auth.db' database not found\n");
  87.             break;
  88.         case 2:
  89.             gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Database Not Accessible**</span>");
  90.             g_print("Unable to read 'auth.db' database\n");
  91.             break;
  92.         case 3:
  93.             gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Unknown User **</span>");
  94.             g_print("Unknown User Account for '%s'\n",user_name);
  95.             break;
  96.         default:
  97.             gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Invalid Password **</span>");
  98.             g_print("Incorrect password for User '%s'!\n",user_name);
  99.     }
  100. }
  101.  
  102. int main( int argc, char *argv[])
  103. {
  104.  
  105.  
  106.     gtk_init(&argc, &argv);
  107.    
  108.     layout = gtk_layout_new(NULL, NULL);
  109.  
  110.     window = g_object_new(GTK_TYPE_WINDOW,
  111.                         "type",GTK_WINDOW_TOPLEVEL,
  112.                         "title","Login",
  113.                         "default-width",660,
  114.                         "default-height",370,
  115.                         "resizable",FALSE,
  116.                         "window-position",GTK_WIN_POS_CENTER,
  117.                         "child",layout,
  118.                         "decorated",0,
  119.                         NULL);
  120.  
  121.     image = g_object_new(GTK_TYPE_IMAGE,"file","logon.png",NULL);
  122.     g_object_set(layout,"child",image,"margin",10,NULL);
  123.    
  124.     lblUser = g_object_new(GTK_TYPE_LABEL,"use-markup",TRUE,"label","<span font_desc=\"16.0\">Username:</span>",NULL);
  125.     lblPass = g_object_new(GTK_TYPE_LABEL,"use-markup",TRUE,"label","<span font_desc=\"16.0\">Password:</span>",NULL);
  126.     err_label = g_object_new(GTK_TYPE_LABEL, "width-request", 270,NULL);
  127.  
  128.     txtUser = g_object_new(GTK_TYPE_ENTRY,NULL);
  129.     txtPass = g_object_new(GTK_TYPE_ENTRY,"visibility",FALSE,NULL);
  130.    
  131.     chkBox = g_object_new(GTK_TYPE_CHECK_BUTTON,"label","Show Password",NULL);
  132.  
  133.     btnLogin = g_object_new(GTK_TYPE_BUTTON,"label","Login","width-request",170,NULL);
  134.  
  135.     gtk_layout_put(GTK_LAYOUT(layout), lblUser, 330, 112-30);
  136.     gtk_layout_put(GTK_LAYOUT(layout), lblPass, 330, 162-30);
  137.     gtk_layout_put(GTK_LAYOUT(layout), txtUser, 460, 110-30);
  138.     gtk_layout_put(GTK_LAYOUT(layout), txtPass, 460, 160-30);
  139.     gtk_layout_put(GTK_LAYOUT(layout), chkBox, 460, 210-30);
  140.     gtk_layout_put(GTK_LAYOUT(layout), btnLogin, 460, 250-30);
  141.     gtk_layout_put(GTK_LAYOUT(layout), err_label, 300, 16);
  142.  
  143.     g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  144.     g_signal_connect (btnLogin, "clicked", G_CALLBACK (onClick), NULL);
  145.     g_signal_connect (chkBox, "toggled", G_CALLBACK (chkBox_cb), txtPass);
  146.     g_signal_connect (txtPass, "changed", G_CALLBACK (txtPass_cb), err_label);
  147.     g_signal_connect (txtPass, "activate", G_CALLBACK (onClick), txtPass);
  148.     g_signal_connect (txtUser, "activate", G_CALLBACK (txtUser_cb), txtPass);
  149.    
  150.     gtk_widget_show_all(window);
  151.  
  152.     gtk_main();
  153.  
  154.     return 0;
  155. }
  156.  
  157.  
  158.  

AIR.
Pages: [1] 2 3 ... 10