digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Programming: PureBasic webbrowser (http://www.digitalfaq.com/archives/avisynth/9197-programming-purebasic-webbrowser.html)

rds_correia 04-18-2004 03:37 PM

PureBasic webbrowser
 
Quote:

Originally Posted by kwag
Now we're off topic, but here it goes :lol:
(Please reply or comment on the programming languages threads, for further discussions )

Quote:

Originally Posted by Latexxx
C#:
Code:

namespace Microsoft.Samples.WinForms.Cs.SimpleHelloWorld {
    using System;
    using System.Windows.Forms;

    public class SimpleHelloWorld : Form {

        [STAThread]
        public static int Main(string[] args) {
            Application.Run(new SimpleHelloWorld());
            return 0;
        }

        public SimpleHelloWorld() {
            this.Text = "Hello World";
        }
    }
}

VB.net:
Code:

Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms

Namespace Microsoft.Samples.WinForms.VB.SimpleHelloWorld

    Public Class SimpleHelloWorld
        Inherits System.Windows.Forms.Form

        'Run the application
        <STAThread()> Shared Sub Main()
            System.Windows.Forms.Application.Run(New SimpleHelloWorld())
        End Sub

        Public Sub New()
            MyBase.New()
            Me.Text = "Hello World"
        End Sub
    End Class

End Namespace

End Sub/Namespace: just stupid

But its your choiche, not mine. Get your program ready![/list]

Yep. It's my choice, and that's exactly why I chose PureBasic for most of the programming I do now.
Unless I have to do a device driver, then I'll do it in C ( which is what C was designed to do. Low level stuff)
Sadly, the industry chose C/C++ for high level applications, which is probably the biggest mistake :!:

If anyone looks closely, those samples only print "Hello World".
Well, this is what I call elegant :!: What follows is the complete source for a complete small web browser
Code:

; ------------------------------------------------------------
;
;  PureBasic - MiniBrowser
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
; This program requiers the Microsoft freely distribuable
; ATL.dll shared library.
;

Procedure ResizeWebWindow()
  ResizeGadget(10, -1, -1, WindowWidth(), WindowHeight()-52)
  ResizeGadget(4, -1, -1, WindowWidth()-185, -1)
  ResizeGadget(5, WindowWidth()-25, -1, -1, -1)
  ResizeGadget(6, -1, -1, WindowWidth(), -1)
EndProcedure


Procedure SizeCallback(WindowID, Message, wParam, lParam)

  ReturnValue = #PB_ProcessPureBasicEvents
 
  If Message = #WM_SIZE
    UpdateStatusBar(0)
    ResizeWebWindow()
    ReturnValue = 1
  EndIf
 
  ProcedureReturn  ReturnValue
EndProcedure


If OpenWindow(0, 100, 100, 500, 300, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "PureBasic MiniBrowser v1.0")

  CreateStatusBar(0, WindowID())
    StatusBarText(0, 0, "Welcome to the world's smallest Browser ! :)", 0)
     
  CreateGadgetList(WindowID())
    ButtonGadget(1,  0, 0, 50, 25, "Back")
    ButtonGadget(2,  50, 0, 50, 25, "Next")
    ButtonGadget(3, 100, 0, 50, 25, "Stop")
 
    StringGadget(4, 155, 5, 0, 20, "http://www.purebasic.com")
   
    ButtonGadget(5, 0, 0, 25, 25, "Go")
   
    Frame3DGadget(6, 0, 30, 0, 2, "", 2) ; Nice little separator
 
    If WebGadget(10, 0, 31, 0, 0, "http://www.purebasic.com") = 0 : MessageRequester("Error", "ATL.dll not found", 0) : End : EndIf
 
  AddKeyboardShortcut(0, #PB_Shortcut_Return, 0)
 
  ResizeWebWindow()
 
  SetWindowCallback(@SizeCallback())
 
  Repeat
    Event = WaitWindowEvent()
   
    Select Event
      Case #PB_Event_Gadget
     
        Select EventGadgetID()
          Case 1
            SetGadgetState(10, #PB_Web_Back)
         
          Case 2
            SetGadgetState(10, #PB_Web_Forward)
         
          Case 3
            SetGadgetState(10, #PB_Web_Stop)
         
          Case 5
            SetGadgetText(10, GetGadgetText(4))
           
        EndSelect     
     
      Case #PB_Event_Menu ; We only have one shortcut
        SetGadgetText(10, GetGadgetText(4))
     
    EndSelect
     
  Until Event = #PB_Event_CloseWindow
 
EndIf

That's what I call elegant ;)
BTW, here's the compiled WebBrowser.exe, weighting at only ~18KB :lol:
http://www.kvcd.net/WebBrowser.exe

Also, here's a link to some of the commercial applications that have been written in PB.
These are VERY expensive applications, so PB is not a toy ( as many see it :!: )
http://www.reelmedia.org/c3/
And look at the prices 8O http://www.reelmedia.org/c3/03.html

So I really think once (not even twice) before coding anything in C/C++ these days :cool:

-kwag

Hey,
About this webbrowser Kwag: is it IE dependable? That is, if I don't have IE on my PC it doesn't work?
Or is it completely independant?
Cheers

kwag 04-18-2004 03:44 PM

Re: PureBasic webbrowser
 
Quote:

Originally Posted by rds_correia
Hey,
About this webbrowser Kwag: is it IE dependable? That is, if I don't have IE on my PC it doesn't work?
Or is it completely independant?
Cheers

Hi Rui,

As the source says on the top:
;
; This program requiers the Microsoft freely distribuable
; ATL.dll shared library.
;


You only need that DLL in your system.
You don't need IE at all :lol:

-kwag

rds_correia 04-19-2004 04:45 PM

Oh man!
Just what I needed.
A small fast and effective webbrowser.
Do I have to buy it or is it freeware :lol:
Cheers buddy

kwag 04-19-2004 06:06 PM

Quote:

Originally Posted by rds_correia
Oh man!
Just what I needed.
A small fast and effective webbrowser.
Do I have to buy it or is it freeware :lol:
Cheers buddy

The browser, or the development system :?:
The browser is free, because I compiled it, and I own a license for the development system ;)
If you want to create and distribute applications, then you must purchase the development system, which I consider one of the best software buys I've ever made :!: 59.00 Euros

-kwag

rds_correia 04-20-2004 03:56 PM

Quote:

Originally Posted by kwag
The browser, or the development system :?:
The browser is free, because I compiled it, and I own a license for the development system ;)

Hehe. I was talking about the browser :wink:

Quote:

Originally Posted by kwag
If you want to create and distribute applications, then you must purchase the development system, which I consider one of the best software buys I've ever made :!: 59.00 Euros
-kwag

That CHEAP :?: 8O
Man :!: I still remember coding BASIC on ZX Spectrum and then on PC with gwbasic and some years later on TurboBasic.
Do you think I've lost the touch (that I never had anyway) :?: 8) :lol:

kwag 04-20-2004 04:10 PM

Quote:

Originally Posted by rds_correia
Man :!: I still remember coding BASIC on ZX Spectrum and then on PC with gwbasic and some years later on TurboBasic.

So did I :mrgreen:
Quote:

Do you think I've lost the touch (that I never had anyway) :?: 8) :lol:
BASIC is so simple, and the new generations of BASICs are completely different to the "old" BASICs.
Now, some are even "Object Oriented", and just about everyone is structured (no more line numbers or needed GOTOs).
So if you are going to give PureBasic a try, you're in for many surprises :D
Clear syntax, easy and coincise language, and powerful as C, but with the speed of assembly language written code. That was one of the key factors that led me to buy and use the system. Plus it's feature rich :!:
Code:

  - Huge set of internal commands (600+) to quickly and easily build any application or game
  - All BASIC keywords are supported
  - Very fast compiler which creates highly optimized executables
  - No external DLLs, runtime interpreter or anything else required when creating executables
  - Procedure support for structured programming with local and global variables
  - Access to full OS API for advanced programmers
  - Easy but very fast 2D game support trough dedicated libraries (DirectX, SDL, ...)
  - Easy and high quality 3D support based on OGRE
  - Optimal use of the available hardware by using highly optimized (assembly) commands
  - Source code is fully portable between AmigaOS, Windows and Linux, for both games and applications
  - Dedicated editor and development environment
  - Integrated debugger to easily trace programming bugs.

BTW, did you try the Pure Racer Demo:?: ;)
http://home.t-online.de/home/misztal/pureracer/

-kwag

Zyphon 04-20-2004 06:38 PM

Quote:

Originally Posted by rds_correia
That CHEAP
Man I still remember coding BASIC on ZX Spectrum and then on PC with gwbasic and some years later on TurboBasic.
Do you think I've lost the touch (that I never had anyway)

OMG! I used to program with ZX Spectrum BASIC to on my trusty old ZX Spectrum +, brings back memories also on my friends Acorn Electron (With was based on the BBC Micro) I liked the Electrons basic with its procedure labels and stuff.

!Sigh! Brings back memories. :)

EDIT: >Here< is a link to said Acorn Electron if any1 might be interested. Also my old trusty ZX Speccy + >Here<. :)

kwag 04-20-2004 06:56 PM

Quote:

Originally Posted by Zyphon

EDIT: >Here< is a link to said Acorn Electron if any1 might be interested. Also my old trusty ZX Speccy + >Here<. :)

Then you might like this ;) http://www.virtualacorn.co.uk/

Hey, don't laugh!, but the first computer I actually bought, was this one :lol: http://www.old-computers.com/museum/...asp?st=1&c=937

-kwag

Zyphon 04-20-2004 07:07 PM

Quote:

Originally Posted by kwag
Quote:

Originally Posted by Zyphon

EDIT: >Here< is a link to said Acorn Electron if any1 might be interested. Also my old trusty ZX Speccy + >Here<. :)

Then you might like this ;) http://www.virtualacorn.co.uk/

Hey, don't laugh!, but the first computer I actually bought, was this one :lol: http://www.old-computers.com/museum/...asp?st=1&c=937

-kwag

Thanks for that virtualcorn link Kwag much appreciated and OMG i remember the trusty old TRS80 by Tandy Radio Shack. I guess the kids of today would just call it a over powered calculator makes me feel old lol.

I also remember the Commodore Vic 20 & the Dragon 32 & 64 or and of course the Commordore 64. Happy days. :D

I know we are off topic a bit here going down that nostalgic road but do you remember the Sinclair QL comp? Check it out >here<

kwag 04-20-2004 07:39 PM

Quote:

Originally Posted by Zyphon
I know we are off topic a bit here going down that nostalgic road but do you remember the Sinclair QL comp? Check it out >here<

Yes, I remember reading about it, but I never had one :(
I did have a Sinclair ZX-81 :mrgreen:
But my biggest fun days in programming, were with my ATARI 800 :D
And I did A LOT with that machine.
Circa 1983, I used an ATARI 800 at work, and I developed a paging encoder application, which was used as a test equipment where I worked at. The program generated Motorola 2 tone sequential paging tones, 5 tone, and also generated IMTS (Improved Mobile Telephone System) signaling to "ring" the car telephones we used at that time. This was pre-cellular times :!:
It also generated what was called "Golay Sequential Code" digital paging format, via the Joystick I/O ports.
What I did was I programmed some of the input ports as output, and then implemented the software in ATARI assembler :lol:
The data would be fed directly to a signal generator, and depending on the menu options, either analog audio out of the sound connector or digital data out of the joystick ports, would be fed via a simple capacitor/resistor attenuator/buffer, and that's how test paging was done at the workbench by the technicians.

I also ripped out the digital logic out of an old Motorola (2 tone) paging terminal, and wrote a program with the ATARI 800 ( again using the joystick ports :cool: ) and then the ATARI would detect via 5 bits ( 4 for data, 1 for activity ) the touch tones that an operator was keying in, and I would map the DTMF data to a lookup table, and generate the corresponding 2 tone or 5 tone paging signals for the addressed pager, key up the transmitter via microwave (Motorola Starpoint, MR-200, and MC-400 channel bank. I still remember the names 8O ), and send the page :lol:
Damn, those were the days :mrgreen:
All done with a 24KB of RAM and at 1.77Mhz and on one 80KB floppy disk :!:

Sorry, now I really went off topic :lol:

-kwag

Zyphon 04-20-2004 08:13 PM

Lol Wow! that sounded like fun work mind you i bet it was hard work sometimes. I remember programming in Assembly language on my Speccy with all those nmemonics for the Z80, me and a friend of mine was working on making a game but we only half completed it before the good old Amiga 500 came out then it was the Amiga/Atari ST war. :D

Off topic again sorry. :oops:

kwag 04-20-2004 08:22 PM

Oh yes, it was fun :mrgreen:
Actually, it was more fun that writing PC software today :?
Those machines were so "rich" in specialized hardware, like the ATARI, which had a special chips (GTIA) for graphics, POKEY, ANTIC, etc., and you could do so much with so little RAM :!:
For example, today, a statement such as:PRINT "Hello World!" in Visual Basic, takes ~2MB in runtime and libraries 8O What a joke :mrgreen:
In 1982, a complete game for an ATARI 800, written in assembler, FORTH or even ATARI BASIC, would fit in 8KB
What happened :?: :lol:
As I've said before: We're going backwards in time :!: :x
Maybe that's one reason I like PureBasic so much :!: It's SO efficient :!:
(Now we're really derailed off topic :rotf: )

-kwag

Zyphon 04-21-2004 04:08 AM

Quote:

Originally Posted by kwag
For example, today, a statement such as:PRINT "Hello World!" in Visual Basic, takes ~2MB in runtime and libraries 8O What a joke :mrgreen:
In 1982, a complete game for an ATARI 800, written in assembler, FORTH or even ATARI BASIC, would fit in 8KB
What happened :?: :lol:
As I've said before: We're going backwards in time :!: :x
Maybe that's one reason I like PureBasic so much :!: It's SO efficient :!:
(Now we're really derailed off topic :rotf: )

-kwag

Yeah I know what you mean I loved programming in BASIC it was the most easiest program to write programs for I dont know why they dont use it so much these days, i mean they could just include a compiler with it that would convert it to machine code. I remember FORTH but I loved assembly language also.

Like you said you could make a game in just 8KB mind I guess games have gotten more complex today.

Also I still have my Commodore Amiga A1200 (Stored in a cubboard somewhere lol) I keep it for nostalgic reasons but to me the Amiga was also more efficient than PC's and storing data like for example it could format a floppy to 880k as opposed to the 720k on the pc.

I had the HDD version and installing games took less compared to the pcs of the day. With tools like Amos and Blitz Basic which I bought both of them and still have lol. :) Alas I never had an Atari ST but a friend of mine did and the music on that machine was awesome to.

Again sorry for the off-topic but I love talking about these old mahines as they pioneered what we take for granted these days. :)

I agree about VB 2MB just to put a PRINT statement is beyond a joke and I feel we need to get back to BASICs lol. :mrgreen:


All times are GMT -5. The time now is 12:43 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.