F.A.Q for PureBasic

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

F.A.Q for PureBasic

Post by BackupUser »

Welcome to the PureBasic forums! :)

These forums contain tons of code and valuable answers to many questions.
So, to have your question answered as quickly as possible, you should first
try searching the entire forums using your keyword(s) as follows, as most
beginner questions have been answered many times over. However, for your
convenience, some of the more frequently asked questions are listed below,
although mainly for Windows users. To search the forums:

(1) Click the Search link at the top-right of this page.
(2) Select Search for all terms for more accurate results.
(3) Type in all relevant keywords (not partial words!).
(4) Click the Search button.

Enjoy your visit, and welcome to the PureBasic community!


Frequently Asked Questions

General

Where is a good introduction to PureBasic for beginners?
Either of these two sites have good information:
http://www.ninelizards.com/purebasic/index.htm

Is there an online reference to all PureBasic commands?
http://www.purebasic.com/documentation/

Why does pasting examples from these forums result in no line breaks?
This occurs if the example wasn't enclosed in "code" tags. Just paste such
examples into WordPad to correct them, and then copy/paste from there into
the PureBasic editor.

Is possible to create a real DOS application in PureBasic?
No, but see: http://www.purebasic.fr/english/viewtopic.php?t=8305

Where can I download third-party user libraries?
A good library collection is at: http://www.purearea.net/

Where can I download a list of Win32 API constants/flags?
http://www.mvps.org/vb/code/Win32api.zip

1. How do I get some good help about Win32 API commands?
2. What does "Cannot find the Win32.hlp file" mean?
3. Why do some commands end in an underscore?

http://www.purebasic.fr/english/viewtopic.php?t=2765

How do I convert "&HFF" in Visual Basic, to PureBasic?
Just replace the &H part with $, thus &HFF is $FF in PureBasic.

How can I do For/Next with a variable for the Step value?
http://www.purebasic.fr/english/viewtopic.php?p=49635


Editing / Form Design

Are there any visual form designers for PureBasic?
PureBasic has a built-in Visual Designer. Or, try these:
http://www.purebasic.fr/english/viewtopic.php?t=23529
http://www.hellobasic.com/pbdev/

How do I enter Unicode characters into the editor?
File menu -> Preferences -> Editor topic -> Use UTF8 encoding.

How can I comment a large group of lines?
Use CTRL+B / ALT+B in the editor, or try this:
http://www.purebasic.fr/english/viewtopic.php?t=3068


Applications

How do I know which OS my app is being compiled on?
http://www.purebasic.fr/english/viewtopic.php?t=8187

How do I know which version of Windows my app is running on?
http://www.purebasic.fr/english/viewtopic.php?t=9780

How do I get the executable name of my app?
a$=Space(999) : GetModuleFilename_(0,@a$,999) : appname$=GetFilePart(a$)

How do I know which folder my app was run from?
a$=Space(999) : GetModuleFileName_(0,@a$,999) : appdir$=GetPathPart(a$)

How do I delete my executable after it's finished running?
http://www.purebasic.fr/english/viewtopic.php?t=4836

How do I detect a right mouse click on a gadget?
Most gadgets return an EventType of #PB_EventType_RightClick, or see:
http://www.purebasic.fr/english/viewtopic.php?t=19124

How do I stop my app from being run twice at the same time?
http://www.purebasic.fr/english/viewtopic.php?p=24945

How do I make my gadgets auto-resize when the user resizes the window?
http://www.purebasic.fr/english/viewtopic.php?t=3700

How do I get the pixel width of a string of text?
http://www.purebasic.fr/english/viewtopic.php?t=6251

How do I drag-and-drop a file onto my app's window?
http://www.purebasic.fr/english/viewtopic.php?t=3649

How do I get my app to run at Windows bootup?
http://www.purebasic.fr/english/viewtopic.php?p=47070

How do I hide my app from the CTRL+ALT+DEL task list?
http://www.purebasic.fr/english/viewtopic.php?t=4486

How do I stop my app's window showing in the TaskBar?
http://www.purebasic.fr/english/viewtopic.php?t=4865

How do I make my app's window be always on top of all others?
StickyWindow(Window,#True)

How do I get a multi-line input requester?
http://www.purebasic.fr/english/viewtopic.php?t=2412

How do I get a multi-line string gadget?
http://www.purebasic.fr/english/viewtopic.php?t=6507

How do I stop the "ding" sound of a string gadget?
http://www.purebasic.fr/english/viewtopic.php?t=3802


Files

How do I check if a file exists?
If FileSize(file$)=-1 : Debug file$+" does not exist" : EndIf

How do I add a line of text to a text file?
http://www.purebasic.fr/english/viewtopic.php?t=3632

How do I send a file to the Recycle Bin instead of deleting it?
http://www.purebasic.fr/english/viewtopic.php?t=3783

How do I search my hard drive for a specific file?
http://www.purebasic.fr/english/viewtopic.php?t=3659


Internet / Communications

How can I check if my PC is online or offline?
http://www.purebasic.fr/english/viewtopic.php?p=49639

How do I connect to my ISP automatically?
http://www.purebasic.fr/english/viewtopic.php?t=4708

How do I download a file from a web page?
http://www.purebasic.fr/english/viewtopic.php?t=2035

How do I send an e-mail?
http://www.purebasic.fr/english/viewtopic.php?t=2489

How do I receive an e-mail?
http://www.purebasic.fr/english/viewtopic.php?t=4795


Mathematics

Why does Str(100/3) result in 33 and not 33.333?
Because the result is of Float type, so use StrF(100/3) instead.

How do I perform a hex-to-decimal conversion?
http://www.purebasic.fr/english/viewtopic.php?t=3477


Windows Operating System

How do I send keystrokes to another application?
http://www.purebasic.fr/english/viewtopic.php?t=3766

How do I create a shortcut to a file?
http://www.purebasic.fr/english/viewtopic.php?t=8668

How do I clear the recent documents menu?
SHAddToRecentDocs_(2,0)

How do I add a document to the recent documents menu?
SHAddToRecentDocs_(2,file$)

How do I take a screenshot of the Desktop?
http://www.purebasic.fr/english/viewtopic.php?t=3695

How do I reboot or shutdown my PC?
http://www.purebasic.fr/english/viewtopic.php?t=3808