• Welcome to Jose's Read Only Forum 2023.
 

PureBasic Corner opened!

Started by Theo Gottwald, July 14, 2013, 03:50:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

After checking the actual State of PureBasic, today, I think its time to open a small place for PureBasic.
It can be used to make programms in x64, but using some of its abilities (built in unzip for example) it can even support PB or other programs with its DLL's.

Besides these features, its Multi Platform Capabilities may be interesting for the one or other project.
Also the licencing is very customer-friendly. Pay once get ALL future Updates free!

For those who may not have seen PureBasic Code until now, here are 3 examples:




FTP-Sample

InitNetwork()

If OpenFTP(0, "127.0.0.1", "test", "test", 0)

  Result = SendFTPFile(0, OpenFileRequester("Choose a file to send", "", "*.*", 0), "purebasic_sent.file", 1)
 
  Repeat
    Debug FTPProgress(0)
    Delay(300)
  Until FTPProgress(0) = -3 Or FTPProgress(0) = -2

  Debug "finished"
 
Else
  MessageRequester("Error", "Can't connect to the FTP server")
EndIf





   PureBasic - 2D Drawing example file


If OpenWindow(0, 100, 200, 300, 200, "2D Drawing Test")

  ; Create an offscreen image, with a green circle in it.
  ; It will be displayed later
  ;
  If CreateImage(0, 300, 200)
    If StartDrawing(ImageOutput(0))
      Circle(100,100,50,RGB(0,0,255))  ; a nice blue circle...

      Box(150,20,20,20, RGB(0,255,0))  ; and a green box
     
      FrontColor(RGB(255,0,0)) ; Finally, red lines..
      For k=0 To 20
        LineXY(10,10+k*8,200, 0)
      Next
     
      DrawingMode(#PB_2DDrawing_Transparent)
      BackColor(RGB(0,155,155)) ; Change the text back and front colour
      FrontColor(RGB(255,255,255))
      DrawText(10,50,"Hello, this is a test")

      StopDrawing()
    EndIf
  EndIf

  ; Create a gadget to display our nice image
  ; 
  ImageGadget(0, 0, 0, 0, 0, ImageID(0))
 
  ;
  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the Event
  ; isn't 0 and we just have to see what have happened...
  ;
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow  ; If the user has pressed on the window close button
 
EndIf

End   ; All the opened windows are closed automatically by PureBasic





DLL - Sample



#TESTDLL = 0

CompilerIf #TESTDLL = 0

  CompilerIf #PB_Compiler_OS = #PB_OS_Windows

    ; These 4 procedures are Windows specific
    ;

    ; This procedure is called once, when the program loads the library
    ; for the first time. All init stuffs can be done here (but not DirectX init)
    ;
    ProcedureDLL AttachProcess(Instance)
    EndProcedure
 
 
    ; Called when the program release (free) the DLL
    ;
    ProcedureDLL DetachProcess(Instance)
    EndProcedure
 
 
    ; Both are called when a thread in a program call or release (free) the DLL
    ;
    ProcedureDLL AttachThread(Instance)
    EndProcedure
 
    ProcedureDLL DetachThread(Instance)
    EndProcedure

  CompilerEndIf

  ; Real code start here..
  ;
  ProcedureDLL EasyRequester(Message$)

    MessageRequester("EasyRequester !", Message$)

  EndProcedure

CompilerElse

  If OpenLibrary(0, "PureBasic.dll") Or OpenLibrary(0, "PureBasic.so")
    CallFunction(0, "EasyRequester", @"Test") 
  EndIf
   
CompilerEndIf


This corner is mainly for Purebasic code, i have removed all postings that have been "discussions about PureBasic".
For discussions about the language itself, open a new Thread please.
Discussions about Oxygen Basic (which i recommend while i do not know much currently) please use Charles Board.

This is specially for Purebasic Code and of corse for conversions from PB for example for x64 code.