Announcement

Collapse
No announcement yet.

5,000 PowerBASIC Classes - Free

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 5,000 PowerBASIC Classes - Free

    in theory - you can expose the entire .net framework for use with powerbasic

    microsoft.com article: ''can i interest you in 5000 classes?'' http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx

    this article shows how to compile a net class down to a dll that can be accessed with com.

    it shows how to do this for vb6.
    i compiled the sample and it shows up just fine in the powerbasic com browser.


    regexwrapper:
    member call equals<&h60020001>(in obj as variant<&h00000000> ) as long
    member call gethashcode<&h60020002>() as long
    member call gettype<&h60020003>() as regexwrappertype
    member call matches<&h60020007>(in input as string<&h00000000> ) as variant
    member call setcompiled<&h60020006>()
    member call setexpression<&h60020004>(in patternstring as string<&h00000000> )
    member call setignorecase<&h60020005>()
    member get tostring<&h00000000>() as string

    you don’t need visual studio .net to compile the sample - there is a bat file for that.
    you will need .net framework 1.1 sdk

    hello powerbasic.net

    added note: got it working with powerbasic!!! http://www.powerbasic.com/support/pb...ad.php?t=24560

    ------------------




    [this message has been edited by stan durham (edited april 15, 2005).]

  • #2
    If you download this to try it out:

    the Bat file to compile the DLL is 'Build and Register.bat'

    the DLL 'wrappers.dll' will be in
    where ever you unzip\5000Classes\Wrappers\bin\wrappers.dll


    ------------------

    Comment


    • #3
      I'll definitely try this. Thank you!
      A known bug with installing the framework error 1935.
      Either reboot or stop windows installer service http://support.microsoft.com/default...b;en-us;308096
      ------------------
      The above failed both after rebooting and stopping the service.
      Now trying some more suggestions from Microsoft
      http://support.microsoft.com/default...en-us;824643#4

      Finally got it to install by clearing temp folder and removing older installations and running MSCONFIG disabling all programs at startup.



      [This message has been edited by Mike Doty (edited April 15, 2005).]
      The world is full of apathy, but who cares?

      Comment


      • #4
        Can't find the file c:\tlbs\wrappers.tlb ?
        Was the batch file supposed to create it?
        Can't reference it from VB6.


        ------------------
        The world is full of apathy, but who cares?

        Comment


        • #5
          >Can't find the file c:\tlbs\wrappers.tlb ?
          >Was the batch file supposed to create it?
          >Can't reference it from VB6.

          look at {\5000Classes\}Wrappers\bin\wrappers.dll
          where {\5000Classes\} is the Dir where you found the Bat file, 'Build and Register.bat'

          I guess you're expected to copy it to 'c:\tlbs\wrappers.tlb' by hand.
          The instructions gave me the impression that is where it would be.

          ------------------


          [This message has been edited by Stan Durham (edited April 15, 2005).]

          Comment


          • #6
            upon further review:

            the file in C:\tbs\ is wrappers.tlb

            VB6 uses C:\tbs\wrappers.tlb

            Also PBCom will open it

            Two of the sample VB6 programs worked OK

            this line in the Bat file does something with the DLL:
            regasm wrappers\bin\wrappers.dll /tlb:c:\tlbs\wrappers.tlb


            ------------------

            Comment


            • #7
              The DownloadAllFiles VB6 project is just plain wrong... You need to
              alter the code in several places. For instance...

              Dim wc As WebClientWrapper

              should be

              Dim wc As Wrappers.WebClientWrapper

              This mistake is repeated multiple times.

              -Ken

              ------------------
              ZCureIT Tech. Home of
              PwrSpell - Spell Checker & SacksPB - XML Parser & Log4PB - Logging Engine
              Mac Application Reviews and More

              Comment


              • #8
                Note that integers are 64bit in dotnet.
                Int32 etc are long and so ..

                I think dot net is a serious future standard platform, i can only tell you the SYSTEM. class stuff is awesome and afaik simply to be executed via com.
                The progid's are there..
                I did not try it but dot net is so large and complete.
                You could explore it a little.
                If you want to know more, follow my dotnet forum on the free beta versions for development tools.
                VB.NET, ASP.NET and so on.
                I'm learning it with these free tools until ASP.NET 20 is available (not beta)
                I learn so much, the framework is so complete(!)


                ------------------
                http://www.hellobasic.com
                PwrDev - Visual Designer for pb/dll, pb/win, pb/cc
                PwrStat - Static library linker for pb/dll or pb/win.
                hellobasic

                Comment


                • #9
                  >dot net is so large and complete

                  She’s pretty, but she sure is a hog.

                  I have code in PB and NET to convert a file from Unix to DOS file format.

                  Both codes just read the file into a string and replace the linefeeds.

                  The file is 54MB

                  PB code:
                  takes: 54mb
                  does it in an eye blink

                  NET:
                  takes: 691mb
                  repeating for emphasizes: 691MB
                  takes several seconds

                  I guess if you have 2-4 gigs of ram - NET would be OK

                  here is the NET source

                  Code:
                  Imports System.IO
                  
                  Public Class cFile
                      Public Source As String
                      Public Destination As String
                  
                      Public Sub UnixToDOS()
                          Dim sr As StreamReader = New StreamReader(Me.Source)
                  
                          Dim s As String = sr.ReadToEnd
                          sr.Close()
                          sr = Nothing
                  
                          s = s.Replace(Chr(13), "")
                          s = s.Replace(Chr(10), Chr(13) + Chr(10))
                  
                          Dim sw As StreamWriter = New StreamWriter(Me.Destination)
                          sw.Write(s)
                          sw.Close()
                          sw = Nothing
                          s = ""
                      End Sub
                  End Class

                  ------------------

                  Comment


                  • #10
                    Got the wrappers.tlb file by getting to a command prompt
                    and into the folder containing the batch file and running
                    it by typing "build and register

                    It created the wrappers.tlb file, but during the process
                    get an error
                    'gacutil' is not recognized twice

                    None of the examples seem to work.


                    ------------------
                    The world is full of apathy, but who cares?

                    Comment


                    • #11
                      when I ran the bat from command prompt - worked ok

                      >Types registered successfully
                      >Assembly exported to 'c:\tlbs\wrappers.tlb', and the type library was registered successfully

                      the VB6 sample in: DownloadAllFiles\
                      got error 'ActiveX component can't create object'

                      the other two samples: DownloadOneFile\ & \Regex Test
                      work OK

                      ============

                      I take it - you don't have VB.NET or C# installed.
                      That could be the difference - even though the author says you don't need them.

                      ------------------


                      [This message has been edited by Stan Durham (edited April 15, 2005).]

                      Comment


                      • #12
                        Correct. I don't have them installed.
                        Have VB.NET, but uninstalled about a year ago.


                        ------------------
                        The world is full of apathy, but who cares?

                        Comment


                        • #13
                          Stan, i can agree on the speed issue, a large part in your app won't need that severe speed.
                          Dotnet (also ASP.NET) makes it possible to use plain (PB) dll's.
                          I don't think one is able to speed up dotnet to similar speeds as pb, but i'm guessing.
                          Unless custom dll's are used.


                          ------------------
                          http://www.hellobasic.com
                          PwrDev - Visual Designer for pb/dll, pb/win, pb/cc
                          PwrStat - Static library linker for pb/dll or pb/win.
                          hellobasic

                          Comment


                          • #14
                            got it working with powerbasic!

                            here is the working sample. http://www.powerbasic.com/support/pb...ad.php?t=24560

                            note: it won't work unless you download the code from microsoft.com
                            and build the tlb file.

                            in theory - you can now access anything in the net framework from pb.
                            ( you would have to have vb.net or c# to build the class interfaces )


                            ------------------

                            Comment


                            • #15
                              I have code in PB and NET to convert a file from Unix to DOS file format.

                              Both codes just read the file into a string and replace the linefeeds.
                              Stan, I think that isn't a good comparision.
                              Strings on PB and .NET are two very different things, as the latter is a sequence of UTF-16 chars.
                              If you need to work with a buffer, you should use a ByteArray.

                              BTW, if I time an about 60MB file CR to CR+LF conversion like the one you proposed, the .NET ver take exactly double the time of the PB one on my PC, witch seems in line with the above mentioned difference.

                              Bye!

                              ------------------
                              Try Online TrID file identifier! Recognize over 1.500 filetypes and counting...
                              Give a powerfull scriptable Lua interface to your application with PowerBLua
                              PBTracer - Tracer / Profiler for PowerBASIC (soon!) - Cell news links
                              -- The universe tends toward maximum irony. Don't push it.

                              File Extension Seeker - Metasearch engine for file extensions / file types
                              Online TrID file identifier | TrIDLib - Identify thousands of file formats

                              Comment


                              • #16
                                >I think that isn't a good comparision

                                True!
                                There is a string buffer class which is supposed to be fast on strings.
                                Plus, I only have 500MB ram.

                                But still 691MB?

                                NET is good stuff.
                                It's here to stay.
                                It's kind of like a Hemmer - it can go a lot of places - makes a big footprint - need to feed it a lot of fule.


                                For what I need to do - PB & SQL Tools works best.


                                ------------------

                                Comment


                                • #17
                                  There is a string buffer class which is supposed to be fast on strings.
                                  I suppose you are referring to System.Text.StringBuilder.
                                  Yes, but, that also deal with strings of UTF-16 chars.

                                  But still 691MB?
                                  I don't see that, neither.

                                  Anyway, .NET give many different choice on doing things, and probably none (or very few) are 1:1 comparable to PB.
                                  Doing the chars replacement on the entire file buffer in memory could be a good approach in PB, but not in .NET. That won't necessary mean that you can't obtain the same result with similar efficency, maybe in a totally different way.

                                  Bye!

                                  ------------------
                                  Try Online TrID file identifier! Recognize over 1.500 filetypes and counting...
                                  Give a powerfull scriptable Lua interface to your application with PowerBLua
                                  PBTracer - Tracer / Profiler for PowerBASIC (soon!) - Cell news links

                                  [This message has been edited by Marco Pontello (edited April 15, 2005).]
                                  -- The universe tends toward maximum irony. Don't push it.

                                  File Extension Seeker - Metasearch engine for file extensions / file types
                                  Online TrID file identifier | TrIDLib - Identify thousands of file formats

                                  Comment


                                  • #18
                                    Stan

                                    I think you have done us a great service here by demonstrating that .NET can be accessed from (non-OOP) PB. I hope we remember this when we (again) talk of .NET and OOP.

                                    Many, many thanks
                                    Keith


                                    ------------------

                                    Comment


                                    • #19
                                      Which is worse?

                                      MS.NET or
                                      PB.COM

                                      If there was a normal dll to use then great but .net via PB's COM implemenation? (Shudder) have fun!

                                      ------------------
                                      Paul Dwyer
                                      Network Engineer
                                      Aussie in Tokyo

                                      Comment


                                      • #20
                                        Finally made some time to actually test this example

                                        Now i know how it works... well i assumed the system object would be available but that was wishful thinking.

                                        The steps are:
                                        1) Create some VB.NET (or other supported language) code.
                                        2) Publish desired methods (export)
                                        3) Compile the VB.NET code to an assembly (special dll created via VBC)
                                        4) Register the assembly (gacutil)
                                        5) Write a TLB file (done for you: regasm /tlb...)

                                        This will be valid to open with the PBCom browser.

                                        I'm not sure if it's a strategic thing to do.
                                        You'll have a lot of new dotnet features but you'll need to register the dll on the end-users computer.
                                        Otherwise you can not reach it via com.

                                        My conclusion:
                                        1) Would be better if could run the assembly in a more direct way.
                                        2) Able to use dotnet without wrapper libraries would be even better.



                                        ------------------
                                        http://www.hellobasic.com
                                        hellobasic

                                        Comment

                                        Working...
                                        X