Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 44

Thread: thinBasic 1.10.x

  1. #31
    Thank you Eros, you are right, after installing the vc2015 x86 runtime on windows xp the thinbasic cJSON module works like charm.
    Thanks

  2. #32
    Hi Eros,

    I love the way you shrunk oxygen.dll to less than 1/3 of its original size (my universe in 150k!). Is it UPX? I could adopt the compression as standard
    Last edited by Charles Pegge; 04-08-2017 at 03:07.

  3. #33
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,128
    Blog Entries
    2
    Rep Power
    10
    Ciao Charles,

    Yes it is UPX with option: "--ultra-brute"
    This option try to compress with 72 different compression methods and at the end it chooses the best
    Option "--brute" is faster because it try only 32 methods and is quite good too in compressing.

    I use UPX for all thinBasic modules DLLs, all EXEs, all bundled EXEs.
    Without UPX thinBasic setup would be more than 35Mb instead of just 16Mb

    Reference: https://upx.github.io/

    Eros
    Last edited by ErosOlmi; 04-08-2017 at 09:59.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #34
    I have been testing UPX compression on all my binaries, without any problems or noticible delays. So I would like to distribute all OxygenBasic binaries UPX-compressed. We will just see if anyone has any major objections on the forum.

    With oxygen.dll 530kb:
    --best 156kb
    --brute 140 kb
    --ultra-brute 140kb

  5. #35
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,128
    Blog Entries
    2
    Rep Power
    10
    Quite ready to release new thinBasic 1.10.3 Beta version

    In the next version there will be just a new feature but ... a great one: new variable type called iDispatch.
    iDispatch variables will let users to interact with COM components that implements Dispatch interfaces like they would be native thinBasic objects.

    It is just a start, many features will be missed (like full dotted notation, COM object events, ForEach <object> in <objectcollection>, ...) but in any case it is a nice start.
    This new feature, when better implemented, will definitely substitute COM module that has never jumped in the direction I wanted.

    Few examples are better then many words.
    Stay tuned ...

    Read and parse and XML file printing child nodes

    uses "Console"
    
    %ELEMENT_NODE                 = 1
    %ATTRIBUTE_NODE               = 2
    %TEXT_NODE                    = 3
    %CDATA_SECTION_NODE           = 4
    %ENTITY_REFERENCE_NODE        = 5
    %ENTITY_NODE                  = 6
    %PROCESSING_INSTRUCTION_NODE  = 7
    %COMMENT_NODE                 = 8
    %DOCUMENT_NODE                = 9
    %DOCUMENT_TYPE_NODE           = 10
    %DOCUMENT_FRAGMENT_NODE       = 11
    %NOTATION_NODE                = 12
    
    
    function TBMain()
      Dim xDoc        as idispatch
      dim xChildNodes as iDispatch
      
      xDoc = NewCom("MSXML.DOMDocument")
    
    
      if IsComObject(xDoc) Then
        xDoc.validateOnParse = False
        xDoc.async = False
        
        If xDoc.Load("https://www.w3schools.com/xml/plant_catalog.xml") Then
          PrintL "Your XML Document loaded successfully."
    
    
          '---Now do something intersting.
          '---Traverse the parsed Document
          xChildNodes = xDoc.childNodes
          DisplayNode(xchildNodes, 0)
    
    
          xDoc = Nothing
        Else
          ' The document failed to load.
          Dim xPE as iDispatch
          ' Obtain the ParseError object
          xPE = xDoc.parseError
    
    
          PrintL "Your XML Document failed to load due the following error."
          printl "Error #.........:", xPE.errorCode 
          printl "Reason..........:", xPE.reason
          printl "Line #..........:", xPE.Line
          printl "Line Position...:", xPE.linepos
          printl "Position In File:", xPE.filepos
          printl "Source Text.....:", xPE.srcText
          printl "Document URL....:", xPE.url
          
          xPE = Nothing
        End If
      Else
        printl "It was not possible to create MSXML.DOMDocument object"
      end If
    
    
      printl "---Press a key to end---"
      WaitKey
    End Function
    
    
    '------------------------------------------------------------------------
    ' Traverse a DOM node collection of nodes
    '------------------------------------------------------------------------
    Function DisplayNode(ByRef xNodes As idispatch, ByVal Indent As Integer)
      Dim xNode       as iDispatch
      Dim xParentNode as iDispatch
      dim xChildNodes as iDispatch
      dim lNode       as Long
      
      Indent = Indent + 2
      
      for lNode = 0 to xNodes.Length - 1
        xNode = xNodes.Item(lNode)
        If xNode.nodeType = %TEXT_NODE Then
          xParentNode = xNode.parentNode
          PrintL $SPC(Indent) & xParentNode.nodeName & ":", xNode.nodeValue
        End If
    '
        If xNode.hasChildNodes Then
          xChildNodes = xNode.childNodes
          DisplayNode(xChildNodes, Indent)
        End If
    
    
        xChildNodes = Nothing
      Next
      
      xNode = Nothing
    End Function
    
    Get information about drive C:

    uses "Console"
    
    dim oFSO      as idispatch
    dim oDrives   as iDispatch
    dim oDrive    as iDispatch
    
    
    oFSO = NewCom("Scripting.FileSystemObject")
    
    
    printl "Creating Scripting.FileSystemObject object ..."
    
    
    if isComObject(oFSO) then
      printl "creation was ok."  in %CCOLOR_FLIGHTGREEN
      PrintL
    
    
      oDrives = oFSO.Drives
      
      if IsComObject(oDrives) Then
    
    
        printl "Number of drives:", oDrives.Count
        printl 
        printl "Get info of Drive C"
        oDrive = oDrives.Item("C")
          
        if IsComObject(oDrive) Then
        
          printl "VolumeName.......", oDrive.VolumeName
          printl "DriveType........", oDrive.DriveType
          printl "DriveLetter......", oDrive.DriveLetter
          printl "TotalSize........", oDrive.TotalSize
          printl "AvailableSpace,,,", oDrive.AvailableSpace
          PrintL
          
        end If
          
      end If
      
    Else
    
    
      printl "Creating Scripting.FileSystemObject failed" in %CCOLOR_FLIGHTRED
      
    end if
    
    
    printl "All done. Press a key"
    
    
    waitkey
    
    Read database data using ADODB COM object

    uses "Console"
    
    dim oCon    as iDispatch
    dim oRec    as iDispatch
    dim oFields as iDispatch
    dim oField  as iDispatch
    
    
    dim lCount  as Long
    
    
    oCon = NewCom("ADODB.Connection")
    
    
    if IsComObject(oCon) then
    
    
      oCon.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & APP_Path & "SampleScripts\ADODB\biblio.mdb")
      
      if oCon.State = 1 then
        printl "State...............:", oCon.State
        printl "Version.............:", oCon.Version
        printl "ConnectionString....:", oCon.ConnectionString
        printl "Provider............:", oCon.Provider
        
        oRec = NewCom("ADODB.Recordset")      'adOpenKeyset=1
        
        string ADO_SQL_Query = "Select * FROM Authors"    'adOpenForwardOnly=0   adLockReadOnly=1   adCmdText=1
        oRec.Open(ADO_SQL_Query, oCon,  1,                      1,                1)
        
        
        printl "Recordset state:", oRec.State
    
    
        '---If state is open then
        if oRec.State Then
    
    
          oRec.MoveLast
          oRec.MoveFirst
          printl "Recordcount:", oRec.Recordcount in %CCOLOR_FLIGHTRED
          PrintL
          
          '---List fields present in recordset
          oFields = oRec.Fields
          if IsComObject(oFields) Then
            printl "Print all fields in ", iTypeInfo_typename(oFields), "collection:"
            for lCount = 1 to oFields.Count
              oField = oFields.Item(lCount-1)
              printl lCount, ") ", oField.Name, oField.Type
            Next
          end If
          
          '---Print data
          PrintL
          printl "Now print out some data:"
          
          lCount = 1
          while not oRec.EOF
            '---Do something
            print lCount, ") " in %CCOLOR_FLIGHTGREEN
            printl oRec.Collect("Author"), oRec.Collect("Year Born")
            incr lCount
            oRec.MoveNext
          Wend
          
          oRec.Close
        end If
        
        oCon.Close
        
      else
        printl "Connection not opened" in %ccolor_flightred
      end if
    
    
      oRec = nothing
      oCon = nothing
    
    
    else
      printl "An error occurred creating ADODB.Connection object" in %ccolor_flightred
    end if
    
    
    printl "---Press a key to end---" in %ccolor_fYellow
    waitkey
    
    Show running process and get few info

    uses "Console"
    
    '------------------------------------------------
    ' List running process
    '------------------------------------------------
    
    
    Dim objWMIService as iDispatch
    dim objItem       as iDispatch
    dim colItems      as iDispatch
    dim strComputer   as String
    
    
    strComputer = "."
    
    
    '---WMI connection to Root CIM
    objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    
    
    if IsComObject(objWMIService) then
    
    
      '---Collection of items
      colItems = objWMIService.ExecQuery("Select * from Win32_Process")
    
    
      if IsComObject(colItems) then
      
        '---Number of items in a collection is always found using .Count property
        for nItems as long = 1 To colItems.Count
          '---Use .ItemIndex with index from 0 to get an item from the collection
          '---Item will be of SWbemObjectSet type
          objItem = colItems.ItemIndex(nItems - 1)
          
          if IsComObject(objItem) then
            'https://msdn.microsoft.com/en-us/library/aa394372(v=vs.85).aspx
            Print "Process:", nItems        in %ccolor_fyellow
            print "", objItem.Name            in %ccolor_flightred
            print "", objItem.ProcessId       in %ccolor_flightcyan
            print "", tstr$(objItem.WorkingSetSize/1024) & " kb"  in %CCOLOR_FLIGHTRED
            print "", objItem.ExecutablePath 'CommandLine
            printl
            
            objItem = Nothing
            
          end if
          
        Next
    
    
        colItems = Nothing
        
      Else
        printl "ExecQuery failed" in %CCOLOR_FLIGHTRED
      end If
      
      objWMIService = Nothing
    
    
    Else
    
    
      printl "GetObject failed" in %CCOLOR_FLIGHTRED
      
    end if
    waitkey
    
    Last edited by ErosOlmi; 09-09-2017 at 09:57.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #36
    Quite ready to release new thinBasic 1.10.3 Beta version
    Hi Eros
    we are waiting


    Thanks

  7. #37
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,128
    Blog Entries
    2
    Rep Power
    10


    I'm fixing last minute bugs and completing help but if you are so brave ...
    point your mouse at the below link and have a look at \thinBasic\SampleScrips\iDispatch\
    |
    |
    |
    |
    |
    |
    \/

    |
    |
    |
    |
    |
    |

    |
    |
    |
    |
    |
    |
    \/

    http://www.thinbasic.biz/projects/th...c_1.10.3.0.zip

    PS: this new feature is only at the very first stage. I'm still studying how to browse iDispatch iTypeLib interface and be able to determine at runtime features exposed by objects.
    If you develop some nice example I will be happy to publish in official thinbasic setup, if you like.
    Last edited by ErosOlmi; 12-09-2017 at 17:58.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  8. #38
    so we don't need Com, or "VBREGEXP" modules when we use iDispatch
    but for some dlls we still need to register it by regsvr32 dllname.dll
    i like mostly the syntax of the new usage of the vbscript regexp. as an example instead of the extremely complex code using "VBREGEXP" module http://www.thinbasic.com/community/s...ll=1#post83112
    here is a very short equivalent using the iDispatch as in the example iDispatch_vbscript.regexp
    don't use numbers (line 6) more than 5 digits to test its primality with regular expressions
    the example appears tall because the many empty lines and many comments
    uses "Console"
    
    '-----------------------------------------------------------------
    'Checks whether or not the user entered a number is prime or not
    '-----------------------------------------------------------------
    Long yourNumber = 97 '123457
    String sNumber  = String$(yourNumber, "1")
    Dim oReg as iDispatch
    
    printl "Creating vbscript.regexp object"
    
    oReg = NewCom("vbscript.regexp")
    
    If IsComObject(oReg) then
      printl "Creation was ok."
      
      printl "
                      '-----------------------------------------------------------------
                      'Checks whether or not a number is prime 
                      '-----------------------------------------------------------------
            "
      'printl expand$("email to check is $sNumber")
      PrintL
      
      oReg.Pattern      = "^1?$|^(11+?)\1+$"
      oReg.IgnoreCase   = %FALSE
      oReg.Global       = %FALSE
    
      PrintL "Cheking pattern is:", oReg.Pattern
      
      ' Test method returns false if a match is found
      If oReg.Test(sNumber) Then
          PrintL "not prime sorry"
      Else
          PrintL "prime number"
      End If
      
      oReg = nothing
    
    Else
    
      printl "Creating vbscript.regexp failed" in %CCOLOR_FLIGHTRED
    
    end if
    
    printl "All done. Press a key"
    
    waitkey
    
    certainly you have done a big job Eros in the dark era in which every one are clicking continuously on his smartPhone which is just wasting the people time and sucking their money.
    i will check the other iDispatch examples

  9. #39
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,128
    Blog Entries
    2
    Rep Power
    10
    Thanks primo,

    Yes, I like programming instead of loosing time on pure socials.

    COM module will be deprecated in future thinBasic version. I already set a note in help file. It was a very rudimentary way to wrap object iDispatch interface.
    VBREGEXP module is too completely deprecated as it was just a wrapper of vbscript.regexp COM object

    Well, the idea is to have the option to interact with any registered COM objects and even on COM objects inside DLL or other kind of files.
    In any case we are just at the very beginning. All started from some code I get from Josť Roca in PowerBasic forum where Josť developed a CallByName function that inspired me: https://forum.powerbasic.com/forum/u...com-callbyname

    I'm also developing some functions able to interact with iTypeLib interface that will let users inspect object.
    Future, future ... I need to stay committed with iDispatch because I've too many ideas in my mind and I must remain committed with my plan
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  10. #40
    Hi Eros

    the new dictionay with iDispatch is easy to understand and remember, how to know the available list of the available methods for the new dictionary
    i have tested example iDispatch_Scripting_Dictionary
    is there a dict.Find ?
    dict.Count works and gives 4 correctly
    but dict.find turns nothing
    other question: why you have named the new creation as "iDispatch" ?

    uses "Console"
    
    Dim dict as iDispatch
    
    printl "Creating dictionary dict ..."
    
    dict = NewCom("Scripting.Dictionary")
    
    if IsComObject(dict) then
    
      printl "Dictionary created."
      dict.CompareMode = 1 '---1 = vbTextCompare - textual comparison. Keys are not case sensitive
      
      printl "Inserting some keys in dictionary ..."
      dict.Add("re","Red")
      dict.Add("gr","Green")
      dict.Add("bl","Blue")
      dict.Add("pi","Pink")
      printl "Done. Number of keys present in dictionary:", dict.Count
      printl "The value of key gr is:", dict.Item("gr")
    
      String st 
      PrintL dict.Count
      st = dict.Find("gr") 
      PrintL st
    
      dict = nothing
      
    else
      printl "An error occurred creating Scripting.Dictionary object" in %ccolor_flightred
    end if
    
    printl "---Press a key to end---" in %ccolor_fYellow
    waitkey
    
    thanks for all your efforts

Page 4 of 5 FirstFirst ... 2345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •