Rapid-Q Documentation by William Yu (c)1999-2000
, Appended by John Kelly
Introduction Chapter 1

01. Rapid-Q Overview /FAQ
(Frequently Asked Questions)

Rapid-Q is a BASIC -like programming language that is now abandoned by its creator William Yu. He sold the rights to RealBasic. (see Preface). However, it is still very functional and you can continue to use it. The compiler is multi-platform, although not completely compatible in terms of the graphical interface, but the underlying language is more or less compatible between platforms. Rapid-Q is available for Windows, Linux, and Unix (Solaris and HP-UX are supported). You can use Rapid-Q to create both GUI and CONSOLE applications, including CGI applications. Rapid-Q generates byte-code as opposed to the native opcode of your processor. This requires an interpreter to read and execute the byte-codes, however, this interpreter is embedded in all your applications, so no extra files are necessary when you distribute your executable. The biggest issue is speed, but depending on what you're using Rapid-Q for, this may not be a factor. Rapid-Q was originally created to provide a free implementation of a BASIC programming language for Windows. 
1.0 Where do you get the latest RapidQ installer? Is it updated regularly?
You can download an installer  for RapidQ (for Windows). It installs the compiler, the IDE, the fixed libraries, the fixed small libraries, the MySQL library, the helpfile (Rapidq.chm) and a riched32.dll (see "can't focus a disabled window" message below). It creates a program group and a desktop icon. It also associates *.bas files with the RQ IDE. An uninstaller is included:
http://www.mididesign.be/rapidq/rqinstall.exe   or try these other sites:

Source code,  documentation, and resources :

      (The largest collection of sample code but slow bandwidth)

Discussion groups and collection of files to members
http://groups.yahoo.com/group/rapid-q/files (members)
http://groups.yahoo.com/group/rapidq/files (members)
Don't expect updates, there is no guarantee of latest releases since RealBasic apparently will not longer support it. The RapidQ2 project is intended to improve the compiler by creating include files with added functionality.

1.0 If RapidQ is a Beta release does the program have a lot of bugs? Will they be fixed?
The bugs are not too bad and many can be avoided by alternative coding. The main reason for this new documentation is to inform programmers of possible bugs and alternative coding options. Obviously there is potential for a bug in your program that will not be fixed since support for the compiler is gone. Don't contact William Yu, or RealBasic about supporting the compiler! You can always look into other basics that have support like Real BASIC, FreeBasic, BCX, or Hot Basic (a rapidQ like language clone). Since there will be no upgrade to the compiler, the only way to improve the language is through coding and API calls. The RapidQ2.INC file was made as a way to start sharing standard code between programmers. It's not so bad, what compiler doesn't have a bug somewhere? 

1.1 How slow is Rapid-Q anyway?
Although Rapid-Q is based on compiling your sources to byte-code, execution isn't as slow as many think. Byte-coded programs, which can be faster than some scripted programming languages. Obviously your programs will be slower than optimized C/C++ code and other compilers that build machine language code. however, it is not all that slow! You will notice slow speed for nested loops, heavy computations, or to perform very low level manipulation to data. For example, reading a single byte from a 1MB file will take longer in Rapid-Q than in most languages, but not so extremely slow. Same with looping I = I + 1 a few thousand times. But in terms of displaying graphics, controls and forms, it's just as fast as any other language. The problem with byte-code is going away with faster and faster computers. If you need real speed you can run a separate DLL written in another language (FreeBasic, BCX, HotBasic, C,but not ActiveX, COM or C++). There is also a way to add assembly language code to your program using RQASM..

1.2 What about bloat-ware?
At a minimum the  Rapid-Q interpreter requires about 300KB (150KB for Linux, 600KB for Sparc). So this is the overhead that all your programs will have. Compared to some Windows programs, this isn't that bad, Most likely your bytecode is less than 50KB anyway (for a moderate/large application), plus any resources and graphics you may want to include of course.

1.3 Does Rapid-Q require extra runtime DLLs?
All your programs require no extra runtime DLLs or externalities. Just distribute your .EXE file and that's it. They should run on any Win95/98/NT system, assuming the end user hasn't done anything to his/her Windows System files. If you compare the bloat-ware of Rapid-Q and the runtime DLLs of other languages, Rapid-Q isn't that bad in terms of bloated size.

1.4 How much memory does Rapid-Q suck out of my programs?
It doesn't suck anything out of your programs (not literally), but it does suck memory out of Windows which in turn limit the amount of memory for your program(s). It really isn't as bad as one might think though. It eats up less than 200KB for virtual, global, and heap memory combined. This is because all variables and objects are created dynamically. The heap/stack memory is the one you should look out for. If your program is deeply nested or involves intense recursion, this can grow and shrink very rapidly. You don't need to worry about cleaning up your objects or variables when your program terminates. Rapid-Q will free all your objects and clean up the memory space for you.

1.5 How easy is it to hack into my programs?
Being a byte-code compiler, if the end user knows how everything is constructed, then it's just a formality. However, Rapid-Q generates a non-standard, or non-specific type byte-code output, which means, unless the user specifically knows what each operation does, it is very very difficult to hack your program. It's easy to hack into your string variables (like any other language), because these things aren't encrypted anyway. In most cases, your program should be safe from snoopers, they might not even know your program is byte-code generated! Unlike Java or other languages, Rapid-Q does not attach any symbol table or extra debugging information to your .EXE.

1.6 Do I need a license to distribute my programs?
No. You don't need a license to use Rapid-Q (it's free), and you definitely don't need any license to distribute or sell your programs. The only agreement you have to worry about is that if you choose to use Rapid-Q, you assume any and all consequences, direct or indirectly from the use of Rapid-Q. Rapid-Q can be used for any task, whether it's profit-seeking or otherwise. You don't pay me a cent, and you don't even have to acknowledge that your program was created with Rapid-Q (although this would be a nice gesture). You CANNOT, however, distribute Rapid-Q (the program itself) and charge for it. You're allowed to bundle Rapid-Q along with your program(s), so long as the user is well informed that it's not buying into Rapid-Q, but rather, buying into your program. How is that done? By not even advertising that your distribution includes a copy of Rapid-Q. Call it the hidden feature.

Q.   Can you make a DLL with RapidQ? Can you link with .LIB files? 
A.  No,
there is no support for making your own DLL, ActiveX, or COM programming interface. However, RapidQ can freely use DLLs written in another language if you can properly set up DECLARE SUB/FUNCTION statements. RapidQ cannot use DLL with COM interfaces. Also there is  no ability for the compiler to do a run-time link with a library file (.LIB). Again FreeBasic, BCX,  FSBL, HotBasic, and RealBasic are good alternatives here.

Q.   What is the latest version of DirextX supported? 
DirectX version 6.0 is the last version supported. DXsound is also version 6.0. The DirectX and Direct3D components are very functional but only represent a subset of all DirectX components, since they were not completed. Support for Direct 3D is through DirectX Retained Mode interface. It will continue to be provided by Microsoft but unfortunately is no longer being upgraded by Microsoft. There is no current support for DirectShow, DirectInput, and newer interfaces. It is possible to use wrapper DLLs (the DLL does the work for you).

Q.   Can you use OpenGL for graphics and is it fast? 
A.  Yes,
you can use OpenGL. There is a set of include files (http://g.slyip.com, or http://groups.yahoo.com/group/rapidq/files ) that allows you to interface to OpenGL (DLL libraries). There are not many examples at the time of this writting and limited texture file formats. The speed of OpenGL is mostly dependent on hardware acceleration, but you will notice that RapidQ will be slower than C++ code for 3D objects with 1000's of vertices. For small number of vertices, you may not notice any difference.

Q.   My virus detection software (Norton) tells me RapidQ has a Trojan virus or some weird virus: 
A.  One is an old problem, that requires you to
update your antivirus software. Also RapidQ compresses the executable with UPX. This makes for a smaller executable but the UPX file compressor might set off some virus dectection software. Unpack your program before running / distribution. Older Norton Antivirus definition files (Dec. 2004), detects the new rapidq3.lib (a Dr electron fixed library) as a "Hacktool." Norton tries to place the file(s) in quarantine. The library does not have a virus. Your options are :
1) Update Norton virus definition file or use the older rapidq3.lib.
2) Exclude the file or folder, and perform a scan. To exclude a file or folder, see:
3)  If Norton AntiVirus is set to its highest sensitivity, then put the virus settings back to their default (standard) level. This may be 
important for AV alerts each time that a program writes to another file.
--Click Norton AntiVirus (NAV) 'options'
--Select Script blocking.
--Check the option "Ask me what to do (recommended)" under the title 'How to respond when a malicious script found'
    See    http://service1.symantec.com/support/nav.nsf/docid/2002041014332806

.   I get a "Cannot focus a disabled or invisible window" error, how do I fix it? 
A.  The error  doesn't cause any problems so just ignore it. The fix is to put the file "riched32.dll " (dated 3/2003) into the directory with RapidQ.EXE and RC.EXE. 
Obtain this file from rapidq source locations such as g.slyip.com (use the search box). The problem is a  result of an newer richedit dll that comes with the newer versions of windows. The IDE must have a disabled or invisible window that it  tries to focus when it first runs, but since earlier versions of the dll in question didn't catch it, it went unnoticed until the dll's were updated recently. Do not register this DLL! Just put it in the RapidQ directory.

QHow to minimize an application to the task bar
A. Use QFormEx (found in rapidq2.inc) or these commands minimize an application to the task bar:
SetWindowLong(Form.Handle, GWL_HWNDPARENT, 0)
SetWindowLong(Application.Handle, GWL_HWNDPARENT, Form.Handle)
Form.WindowState = wsMinimized
Also the file http://groups.yahoo.com/group/rapidq/files/Scheduler.bas shows you how  to manage a tray popup

Q How do you to put a bitmap in the ClipBoard?
A.  Draw to a QBitmapEx (found in rapidq2.inc) then use Bitmap.PasteToClipboard. 
The width, height and PixelFormat of theQBitmapEx object affect how it looks.

Q.  How do you find out if my application is already running, also called previous instance of your application.
A.  Look on the web for the Previnst.Bas example:
1) One solution is use FindWindow like this previnst.bas example:
http://citymap.getmyip.com  or http://g.slyip.com

Q.  How can you create a custom event?
A.  Yes, you can use an existing event like OnMouseMove, or make a custom event using Windows messages.  See the source code for QFormEx to see custom events that hook the WndProc Callback function with Windows messages.

Here is an example by Pavel Minayev:
' A short example demonstrating custom events 
' QCircle is a simple control that looks a circle, and it  provides OnHitCircle event, which is called each time the 
' user clicks inside of the circle. It also passes one argument  which is the distance from the center of the circle to 
' the point clicked. 

$INCLUDE "rapidq.inc"
' This declaration is used as a template for event handlers 
' for OnHitCircle event 
 ' Declare an event based on previously declared handler template 
 OnHitCircle AS EVENT(HitCircleEvent)
 EVENT OnPaint
  WITH QCircle
   .Circle(0, 0, .Width, .Height, clWindowText, clBtnFace)
 EVENT OnMouseDown(Button AS LONG, x AS LONG, y AS LONG, Shift AS LONG)
  WITH QCircle
   d = SQR((x - .Width / 2) ^ 2 + (y - .Height / 2) ^ 2)
   ' If cursor was inside of the circle, fire the event 
   IF d <= .Width / 2 THEN CALLFUNC(.OnHitCircle, d)
  Width = 100
  Height = 100
' *************   Test code   *********
SUB Circle1_HitCircle(d AS SINGLE)
 SHOWMESSAGE "Distance from center: " + STR$(d)
 Width = 300
 Height = 300
 CREATE Circle1 AS QCircle
  OnHitCircle = Circle1_HitCircle
Preface Contents Up   Next Chapter