Guidance
指路人
g.yi.org
software / RapidQ / RQ Doc / html / otherdetail.html

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
Appendix C: Other Detailed Keywords
Rapid-Q Documentation by William Yu (c)1999-2000 Appendix C: Other Detailed Keywords


Other Detailed Keywords

Most of these have the same functionality as QBasic, so you could just as easily look them up there. Again, when I refer to Unix, I mean Linux & Unix.

ABSMATH FunctionWindows/Unix

A math function that returns the absolute value of a numeric expression.

Syntax: ABS(numeric-expression)
A% = ABS(-123)

Details:
The absolute value of function returns the unsigned magnitude of its argument. So, ABS(-1) and ABS(1) are both 1.


ACOSMATH FunctionWindows/Unix

A math function that returns the arccosine of a numeric expression.

Syntax: ACOS(numeric-expression)
D# = ACOS(0.55)

Details:
Numeric-expression is in the range -1 to 1.


ASCSTRING FunctionWindows/Unix

A string processing function that returns a numeric value that is the ASCII code for the first character in a string expression.

Syntax: ASC(string-expression)
A% = ASC("A")



ASINMATH FunctionWindows/Unix

A math function that returns the arcsine of a numeric expression.

Syntax: ASIN(numeric-expression)
D# = ASIN(0.55)

Details:
Numeric-expression is in the range -1 to 1.


ATN/ATANMATH FunctionWindows/Unix

A math function that returns the arctangent of a numeric expression.

Syntax: ATN(numeric-expression)
D# = ATN(0.9)

Details:
Numeric-expression is the angle expressed in radians.


BIN$CONVERSION FunctionWindows/Unix

A binary conversion function which will convert any positive INTEGER number to its binary representation.

Syntax: BIN$(numeric-expression)
S$ = BIN$(123)

Details:
Negative numbers are not supported, and so results are not defined.


BINDPOINTER FunctionWindows/Unix

BIND will bind a variable as a function pointer.

Syntax: BIND variable TO function
DECLARE SUB MyFunc(X AS INTEGER)
BIND A% TO MyFunc

Details:
To invoke this function pointer, use CALLFUNC.


CALLBACK/CODEPTRADDRESS FunctionWindows

CODEPTR (or CALLBACK) will return the absolute address of a SUB or FUNCTION.

Syntax: CODEPTR(MySUB)
SUB MySUB
END SUB
A& = CODEPTR(MySUB)

Details:
Use this function for CALLBACK routines. Not all cases are implemented, results may vary depending on the CALLBACK and the type of parameters it receives.


CALLFUNCPOINTER FunctionWindows/Unix

CALLFUNC will execute the function pointer that was bound by using BIND.

Syntax: CALLFUNC(fptr, param1, param2, ...)
CALLFUNC(FPtr, 10, 20)
PRINT CALLFUNC(FPtr2, 10, 20)

Details:
Depending on how you BIND your function pointer, you can either call CALLFUNC as a statement or a function. Make sure to supply the necessary number of parameters, else you will receive a compile error. Passing function pointers as parameters is not yet implemented, but you can read up on Chapter 11 to see how to emulate this.


CEILMATH FunctionWindows/Unix

A math function that rounds a numeric expression up toward positive infinity.

Syntax: CEIL(numeric-expression)
A% = CEIL(66.2) '-- Returns 67



CHDIRSYSTEM StatementWindows/Unix

CHDIR will change the current working directory for your application.

Syntax: CHDIR string-expression
CHDIR "c:\windows"



CHR$STRING FunctionWindows/Unix

A string processing function that returns a one-character string whose ASCII code is the argument.

Syntax: CHR$(numeric-expression)
A$ = CHR$(66)

Details:
Numeric-expression should be in the range 0-255.


CINTCONVERSION FunctionWindows/Unix

A conversion function that converts a numeric expression to an integer by rounding the fractional part of the expression.

Syntax: CINT(numeric-expression)
A% = CINT(66.7)

Details:
Implemented for compatibility with QBasic, you can use the more logical function, ROUND, instead.


CLNGCONVERSION FunctionWindows/Unix

A conversion function that converts a numeric expression to an integer by rounding the fractional part of the expression.

Syntax: CLNG(numeric-expression)
A% = CLNG(66.7) '-- equals 67

Details:
Implemented for compatibility with QBasic, you can use the more logical function, ROUND, instead.


CONSTStatementWindows/Unix

A non-executable statement that declares symbolic constants to use in place of numeric or string values.

Syntax: CONST constantname [ as Datatype ]= expression
CONST False = 0
CONST True AS LONG = NOT False
CONST A$ = "Hi world!"
CONST Char = CHR$(66)
CONST Combine = A$ + Char

Details:
Expression can be any value, numeric or string. Rapid-Q will decipher what the constant value will be bound to (ie. a string or a numeric variable) if the constantname is not followed by a type-declaration character (%. &, !, #, $, etc...).


CONVBASE$CONVERSION FunctionWindows/Unix

A conversion function which takes the string expression represented in a specified base to be converted to another specified base determined by the arguments passed.

Syntax: CONVBASE$(string-expression, frombase, tobase)
S$ = CONVBASE$("FFD", 16, 2) '-- Convert from base 16 to 2
S$ = CONVBASE$("287", 10, 16) '-- Convert from base 10 to 16

Details:
Negative numbers are not supported.


COSMATH FunctionWindows/Unix

A math function that returns the cosine of an angle given in radians.

Syntax: COS(numeric-expression)
PI = 3.14153
C# = COS(PI)

Details:
Numeric-expression is the angle expressed in radians.


DATAStatementWindows/Unix

A non-executable statement that stores the numeric and string constants used by a program's READ statements.

Syntax: DATA {constant|EXECUTE(...)}[,...]
DATA my dog ate my homework, "oh, boy!", 34.4
DATA EXECUTE(LEFT$("Hello", 2, 3))

Details:
Constant is any valid numeric or string constant. If a string constant contains commas, colons, or leading or trailing spaces you want to preserve in your program, you must enclose the string in double quotes. You can also execute code by using the EXECUTE keyword. The return value of this executed code will be the value returned to your READ statement.


DATE$SYSTEM FunctionWindows/Unix

A function that returns a string containing the current date formatted as MM-DD-YYYY. Where MM = month (1-12), DD = day (1-31) and YY = year (1980-2099)

Syntax: DATE$
PRINT DATE$

Details:
Unlike QBasic where you can set the current date using the DATE$ statement, you cannot do this under Rapid-Q.


DECStatementWindows/Unix

Decrements numeric variable by one, or by the amount specified.

Syntax: DEC(variable [, amount])
DEC(I)
DEC(I, 10)



DEF...StatementWindows/Unix

DEFBYTE, DEFDBL, DEFDWORD, DEFINT, DEFLNG, DEFSHORT, DEFSNG, DEFSTR, DEFWORD are declaration statement that names one or more variables and allocates storage space for them.

Syntax: DEFINT variable[(subscripts)] [, ...]
DEFSTR A, B, C="Hello", D, E
DEFINT I=99, J(100,10), K

Details:
You cannot specify a range of variables, for example: DEFINT A-Z works fine under QBasic, but not Rapid-Q. You can initialize each variable as demonstrated above. DEF... statements are equivalent to calling DIM, but can save you a lot of typing. To initialize an array, wrap the values around curly braces {...}. For Example,
DEFINT A(1 TO 10) = {1,2,3,4,5,6,7,8,9,10}
Initializes elements 1 through 10 with the values 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 respectively.


DELETE$STRING FunctionWindows/Unix

A function that deletes part of a string.

Syntax: DELETE$(string-expression, start, length)
A$ = DELETE$("Hello world", 2, 3) '-- Result: Ho world


DIMStatementWindows/Unix

Declaration statement that names one or more variables and allocates storage space for them.

Syntax: DIM variable[(subscripts)] AS type
DIM A AS INTEGER, B(2,5,3,9,2) AS INTEGER
DIM S AS STRING
DIM Form AS QFORM

Details:
Use the optional (subscripts) to declare the size of arrays, up to 5 dimensions.


DIR$SYSTEM FunctionWindows

A system function used to obtain the first/next file corresponding to a specified filespec.

Syntax: DIR$[(file-spec, attribute)]
FileName$ = DIR$("*.*", 0) '-- Get first file
FileName$ = DIR$ '-- Get next file

Details:
File-spec specifies a filename or path (which can include wildcards characters). Calling DIR$ with no parameters return additional filename matches. If no matches exist (or all matches have been exhausted), DIR$ returns an empty string. DIR$ returns all regular files as well as any special files specified in the attribute parameter.
Here are some valid file attributes, you can combine
them by using OR (ie. faReadOnly OR faDirectory)

&H1 = faReadOnly       &H8 = faVolumeID
&H2 = faHidden        &H10 = faDirectory
&H4 = faSysFile       &H20 = faArchive
                      &H3F = faAnyFile
To obtain additional information on the currently matched file, use the FileRec properties.
FileRec.FileName    - Returns Windows long file name
FileRec.ShortName   - Returns the short file name
FileRec.Date        - Returns the file date as a string
FileRec.Time        - Returns the file time as a string
FileRec.Size        - Returns the file size
FileRec.FileTime    - Returns the file time as an integer
You can use FileRec.FileTime to compare file times. So a newer file will have a FileTime greater than an older file.


DIREXISTSSYSTEM FunctionWindows

A function that returns 0 if directory does not exist, non-zero otherwise.

Syntax: DIREXISTS(string-expression)
A = DIREXISTS("c:\windows")



DOEVENTSRAPID-Q SpecificWindows

Returns control to the operating system to process the events in its queue, and returns back control to the program once done.

Syntax: DOEVENTS
DO
    DOEVENTS
LOOP

Details:
DoEvents should normally be used for long-running processes (ie. long loops or anything else that eats up the CPU), so that the user can abort the process if necessary. DoEvents can also be used to handle multiple forms.


ENDStatementWindows/Unix

Terminates your program.

Syntax: END
END

Details:
Call END to terminate your application, but if there are any Windows still opened, you should close them first.


ENVIRONSYSTEM StatementWindows/Unix

A statement used to set or modify an environment variable.

Syntax: ENVIRON string-expression
ENVIRON "PATH=c:\windows"
ENVIRON "TEST what"

Details:
String-expression must have the form
parametername=text
or
parametername text
Everything to the left of the equal sign or space is assumed to be a parameter, and everything to the right, text. If the parametername has not previously existed in the environment string table, it is appended to the end of the table. If a pametername already exists, it gets deleted and the new parametername is appended to the end of the table.


ENVIRON$SYSTEM FunctionWindows/Unix

A function that returns an environment string.

Syntax: ENVIRON$(environment-string)
A$ = ENVIRON$("PATH")

Details:
It is not possible, at this time, to retrieve an environment string by its index.


EXPMATH FunctionWindows/Unix

A math function that returns the exponential function (e raised to the power of n).

Syntax: EXP(numeric-expression)
A# = EXP(1)



EXTRACTRESOURCERESOURCE StatementWindows/Unix

A statement that extracts a resource, from the current program, to a file.

Syntax: EXTRACTRESOURCE resource-value, filename
EXTRACTRESOURCE Resource(0), "test.bmp"

Details:
The resource-value is the absolute position of the resource within the current program. To find the absolute position of the resource, see also RESOURCE(), and RESOURCECOUNT.


FIELD$STRING FunctionWindows/Unix

A function that returns a field (or token) separated by deliminators.

Syntax: FIELD$(Source-string, deliminator-string, field-number)
A$ = FIELD$("John&Doe&555-1234", "&", 2)   '-- Returns Doe
A$ = FIELD$("John&&Doe&&555-1234", "&&", 3)   '-- Returns 555-1234



FILEEXISTSSYSTEM FunctionWindows/Unix

A function that returns 0 if file does not exist, non-zero otherwise. The current working directory is searched for the file if no path is specified.

Syntax: FILEEXISTS(string-expression)
A = FILEEXISTS("rapidq.exe")



FIXMATH FunctionWindows/Unix

A function that removes the fractional part of a number.

Syntax: FIX(numeric-expression)
A% = FIX(342.97)



FLOORMATH FunctionWindows/Unix

A math function that rounds a numeric expression down toward negative infinity.

Syntax: FLOOR(numeric-expression)
A% = FLOOR(66.7) '-- Returns 66



FORMAT$STRING FunctionWindows/Unix

A function that returns a formatted string assembled from a Pascal style format string and a series of arguments. The Pascal style format string closely resembles C style format strings, but definitely not VB compatible.

Syntax: FORMAT$(Format-string, arg1, arg2, ...)
A$ = FORMAT$("Location: %s %4d %-10.4g", "Any", 1234, 55.39)   '-- Returns Location: Any 1234 55.39
Details:
Format strings passed to the string formatting routines contain two types of objects--plain characters and format specifiers. Plain characters are copied verbatim to the resulting string. Format specifiers fetch arguments from the argument list and apply formatting to them. Format specifiers have the following form:
"%" [index ":"] ["-"] [width] ["." prec] type
A format specifier begins with a % character. After the % come the following, in this order:
An optional argument index specifier, [index ":"]
An optional left justification indicator, ["-"]
An optional width specifier, [width]
An optional precision specifier, ["." prec]
The conversion type character, type
The following table summarizes the possible values for type:
d Decimal. The argument should be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros.
e Scientific. The argument should be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string--a default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits.
f Fixed. The argument should be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative. The number of digits after the decimal point is given by the precision specifier in the format string--a default of 2 decimal digits is assumed if no precision specifier is present.
g General. The argument should be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string--a default precision of 15 is assumed if no precision specifier is present. Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses fixed point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format.
n Number. The argument should be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format corresponds to the "f" format, except that the resulting string contains thousand separators.
m Money. The argument should be a floating-point value. The value is converted to a string that represents a currency amount.
s String. The argument must be a string. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.
x Hexadecimal. The argument should be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros.

Conversion characters may be specified in uppercase as well as in lowercase--both produce the same results.
An index specifier sets the current argument list index to the specified value. The index of the first argument in the argument list is 0. Using index specifiers, it is possible to format the same argument multiple times. For example Format$("%d %d %0:d %d", 10, 20) produces the string "10 20 10 20".


FRACMATH FunctionWindows/Unix

A function that returns the fractional part of a number.

Syntax: FRAC(numeric-expression)
A# = FRAC(342.97)



HEX$CONVERSION FunctionWindows/Unix

A function that returns the hexidecimal (base 16) representation of the (base 10) numeric expression.

Syntax: HEX$(numeric-expression)
A$ = HEX$(123)

Details:
Negative numbers are supported. In the Windows version, the string is pre-padded with 0's to fit the string length of 8.


IIFFunctionWindows/Unix

The immediate IF function returns one of two parts depending on the evaluation of an expression. Notice that both parts are evaluated, whether the expression returned true or false, so watch for undesirable side effects.

Syntax: IIF(expression, true-expr, false-expr)
A$ = IIF(6 > 5, "TRUE", "FALSE") '-- returns TRUE



INCStatementWindows/Unix

Increments numeric variable by one, or by the amount specified.

Syntax: INC(variable [, amount])
INC(I)
INC(I, 10)



INITARRAYARRAY StatementWindows/Unix

Initializes an array with the corresponding values.

Syntax: INITARRAY(Array, value [, ...])
DIM A(1 TO 100) AS INTEGER
INITARRAY(A, 55, 234, 45, 99)

Details:
Equivalently:
DEFINT A(1 TO 100) = {55, 234, 45, 99}

Initializing arrays as opposed to looping through each one saves a bit of time.


INPI/O FunctionWindows/Unix

A device I/O function that returns the byte value read from an I/O port.

Syntax: INP(port)
A% = INP(&H3C9)

Details:
Port is any word value between 0 and 65535. Return value is in the range 0 to 255.


INPWI/O FunctionWindows/Unix

A device I/O function that returns the word value read from an I/O port.

Syntax: INPW(port)
A = INPW(&H3C9)

Details:
Port is any word value between 0 and 65535. Return value is also in the range 0 to 65535.


INSERT$STRING FunctionWindows/Unix

A function that returns a string with an inserted substring beginning at a specified index.

Syntax: INSERT$(insert-string, source-string, index-number)
A$ = INSERT$("hi", "Hello", 3) '-- returns Hehillo



INSTRSTRING FunctionWindows/Unix

A function that compares 2 strings and returns the position of the find-string with respect to the search-string. If found, INSTR returns the index position of the find-string, 0 otherwise.

Syntax: INSTR([start,] search-string, find-string)
A% = INSTR("Hello", "ll") '-- returns 3
A% = INSTR(4, "hehe they", "he") '-- returns 7



INTMATH FunctionWindows/Unix

A function that returns the largest integer less than or equal to a numeric-expression. Fractional part is truncated.

Syntax: INT(numeric-expression)
A& = INT(342.97)



KILLSYSTEM StatementWindows/Unix

A statement that removes a disk file.

Syntax: KILL filespec
KILL "mydocuments.txt"
KILL "*.c"



KILLMESSAGERAPID-Q SpecificWindows

A statement that removes a message from the queue.

Syntax: KILLMESSAGE hWnd, Message
KILLMESSAGE form.handle, WM_CHAR

Details:
Ideally, KillMessage should be used inside an event, such as OnKeyDown, to remove any messages you don't want processed further.


LBOUNDARRAY FunctionWindows/Unix

A function that returns the lower bound of the array.

Syntax: LBOUND(arrayname [,dimension])
DIM A(-50 TO 100) AS INTEGER
L% = LBOUND(A) '-- Returns -50

Details:
If the array has multiple dimensions, you can use the optional dimension argument to check the lower bound of each one.


LCASE$STRING FunctionWindows/Unix

A string function that returns a string expression with all letters lower-case.

Syntax: LCASE$(string-expression)
A$ = LCASE$("HELLO") '-- returns hello



LEFT$STRING FunctionWindows/Unix

A string function that returns a string consisting of the leftmost n characters of a string.

Syntax: LEFT$(string-expression, n)
A$ = LEFT$("Hello",2) '-- returns he



LENSTRING FunctionWindows/Unix

A function that returns the number of characters in a string.

Syntax: LEN(string-expression)
A% = LEN("HELLO") '-- returns 5

Details:
LEN will not return the number of bytes required by a variable. This option is available under QBasic.


LFLUSHPRINTER StatementWindows

A statement used to begin a print job.

Syntax: LFLUSH
LPRINT "print this line"
LFLUSH '-- call this to start printing

Details:
You should call LFLUSH after you're satisfied that you want to start printing. If you don't call LFLUSH, then whenever your application terminates is when your document will start its print job.


LIBRARYINSTDLL FunctionWindows

Returns the handle to the DLL module. If the DLL hasn't been loaded yet or is not found, this function returns 0.

Syntax: LIBRARYINST(DLLName)
DECLARE FUNCTION UpdateWindow LIB "USER32" ALIAS _
          "UpdateWindow" (hWnd AS LONG) AS LONG
UpdateWindow(0)     '-- Using function will load DLL
hInst& = LIBRARYINST("USER32")

Details:
Declaring a function as a DLL function does not automatically load the DLL. The DLL is loaded once the function is used. Please note that library names should match, so in your declaration for LIB "USER32" ... to find this library, you must match that same name. ie. LIBRARYINST("USER32.DLL") returns 0, it must be "USER32" in this particular case. See also UNLOADLIBRARY.


LOGMATH FunctionWindows/Unix

A math function that returns the natural logarithm of a numeric expression.

Syntax: LOG(numeric-expression)
A# = LOG(10)



LPRINTPRINTER StatementWindows

A statement just like PRINT except all output is directed to the default printer. Make sure to call LFLUSH to start the print job.

Syntax: LPRINT [expressions][{;|,}][...]
LPRINT "print this line"
LFLUSH

Details:
You should call LFLUSH after you're satisfied that you want to start printing. If you don't call LFLUSH, then whenever your application terminates is when your document will start its print job.


LTRIM$STRING FunctionWindows/Unix

A string function that returns a string with leading spaces removed.

Syntax: LTRIM$(string-expression)
A$ = LTRIM$(" Hello") '-- returns Hello



MEMCMPMEMORY FunctionWindows/Unix

A memory function that compares 2 memory addresses and returns 0 if the memory contents do not match, or non-zero otherwise.

Syntax: MEMCMP(ptr1, ptr2, count)
DEFINT I=10, J=10
A% = MEMCMP(VARPTR(I), VARPTR(J), SIZEOF(INTEGER))



MEMCPYMEMORY FunctionWindows/Unix

A memory function that copies n bytes of memory from source to destination.

Syntax: MEMCPY(destination, source, n)
DEFINT I=90, J=10
'-- After MEMCPY, I should equal 10
MEMCPY(VARPTR(I), VARPTR(J), SIZEOF(INTEGER))



MEMSETMEMORY FunctionWindows/Unix

A memory function that initializes a memory blocks.

Syntax: MEMSET(ptr, char, size)
DIM IntArray(1 TO 10) AS INTEGER
MEMSET(VARPTR(I(1)), 0, 10*SIZEOF(INTEGER))



MESSAGEBOXRAPID-Q SpecificWindows

Displays a simple message box with prompts. This implements Window's MessageBox API function.

Syntax: MESSAGEBOX(message, title, flags%)
IF MessageBox("Close this form?", "Close", 1) = 1 THEN
    '-- Close form
END IF

Details:
See Windows API Help file for valid flags.


MESSAGEDLGRAPID-Q SpecificWindows

Displays a message box with an icon and a user defined caption. This implements Window's MessageBoxEx API function.

Syntax: MESSAGEDLG(string-expression, msgType, msgButtons, helpContext)
IF MessageDlg("Close this form?", mtWarning, mbYes OR mbNo, 0) = mrNo THEN
    '-- Don't close form
END IF

Details:
msgType is used to display the type of icon that will be displayed in your message box.
0 = mtWarning      3 = mtConfirmation
1 = mtError        4 = mtCustom
2 = mtInformation
msgButtons is used to display custom dialog buttons. To display more than one message button, just OR them.
1 = mbYes       32 = mbAbort
2 = mbNo        64 = mbRetry
4 = mbOK       128 = mbIgnore
8 = mbCancel   256 = mbAll
16 = mbHelp
helpContext is ignored for now.


MID$STRING FunctionWindows/Unix

A string function that returns a substring with n chracters starting from i of string-expression.

Syntax: MID$(string-expression, i, n)
A$ = MID$("Hello",3,2) '-- returns ll

Details:
You cannot use MID$ in this way:
MID$(A$, 1, 1) = "G"
Under QBasic, this valid statement replaces the first character from A$ with "G". To acheive the same effect under Rapid-Q, please use the REPLACE$ string function.


MKDIRSYSTEM StatementWindows/Unix

A statement that creates a new directory.

Syntax: MKDIR pathspec
MKDIR "abc"

Details:
MKDIR will not rewrite a directory if one already exists, if no path is specified, the directory is created in the current working directory.


OUTI/O StatementWindows/Unix

A device I/O statement that sends a byte value to a machine I/O port.

Syntax: OUT port, value
OUT &H3C9, 128

Details:
  • Port is any word value between 0 and 65535.
  • Value is any byte value between 0 and 255.


  • OUTWI/O StatementWindows/Unix

    A device I/O statement that sends a word value to a machine I/O port.

    Syntax: OUTW port, value
    OUTW &H378, 128

    Details:
  • Port is any word value between 0 and 65535.
  • Value is any byte value between 0 and 65535.


  • PLAYWAVRAPID-Q SpecificWindows

    Plays a .WAV file or a .WAV resource.

    Syntax: PLAYWAV wavfilename|wavresource, sndOptions
    $RESOURCE Welcome_WAV AS "welcome.wav"
    PLAYWAV "welcome.wav", SND_ASYNC OR SND_LOOP
    PLAYWAV Welcome_WAV, SND_ASYNC OR SND_LOOP

    Details:
    sndOptions determine how the wav file is played back.
    0 = SND_SYNC     '-- waits for wav to finish
    1 = SND_ASYNC    '-- background play
    3 = SND_LOOP     '-- Loop wav once finished playing
    You can combine SYNC or ASYNC with LOOP by OR'ing them. If your WAV file is not finished playing when you close your application, you will receive an access violation. You can stop the .WAV by passing an empty string as a filename.


    POSTMESSAGERAPID-Q SpecificWindows

    A WinAPI call to PostMessage, does not block.

    Syntax: POSTMESSAGE hWnd, uMsg, wParam, lParam
    POSTMESSAGE Form.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0

    Details:
    PostMessage is a WinAPI call so instead of filling this entire page with information you can look up this function in your WinAPI manual/help file.


    QUICKSORTSORTING StatementWindows/Unix

    QUICKSORT, aptly named, can be used to sort your arrays of any type, except Objects/UDTs of course. It, obviously, uses the QuickSort algorithm to perform the sort.

    Syntax: QUICKSORT(Array-begin, Array-end, ASCEND|DESCEND)
    DIM A(1000) AS INTEGER
    '-- put stuff in A
    QUICKSORT(A(10), A(500), ASCEND) '-- sorts elements 10..500

    Details:
    The pivot element in the above example is A(10), so if you want randomness, you'll have to replace A(10) with some random element from A(10)..A(500) in the above example. You can also sort multi-dimensional arrays and "span sort" arrays.

    Span sorting:
               DIM A(1 TO 100) AS LONG
               DIM B(1 TO 100) AS LONG
               DIM C(1 TO 100) AS LONG
    
               '--- puts some values into array A, B, C
               RANDOMIZE TIMER
               FOR I = 1 TO 100
                   A(I) = RND(50000)
                   B(I) = RND(50000)
                   C(I) = RND(50000)
               NEXT
    
               QUICKSORT A(1), C(100), ASCEND
               PRINT A(1)," ",B(1)," ",C(1)
               
    As long as you DIM the arrays "side by side" they will share a contiguous space of memory, this means you can sort from the start of memory address A(1) to the end of memory address C(100). This technique is not recommended, but if you can find a use for it, go ahead.


    RANDOMIZEMATH StatementWindows/Unix

    Initializes (reseeds) the random-number generator.

    Syntax: RANDOMIZE [numeric-expression]
    RANDOMIZE TIMER

    Details:
    If argument is omitted, randomize will default as RANDOMIZE TIMER.


    READStatementWindows/Unix

    A statement that reads values from a DATA statement and assigns the values to variables.

    Syntax: READ variablelist
    READ A%, S$, P(1,2)

    Details:
    Variablelist is made up of one or more variables, separated by commas, which are to receive the data. The variables may be string or numeric.


    REDIMStatementWindows/Unix

    Declaration statement that changes the space allocated to an array that has already been declared by DIM, preserving as much of the data as possible.

    Syntax: REDIM variable[(subscripts)] AS type
    DIM B(20) AS INTEGER
    REDIM B(100) AS INTEGER

    Details:
    If the array has not yet been declared by DIM, REDIM will be equivalent to calling DIM (except when dealing with components, in which case you'll receive a compiler error). You cannot change the data type for the array, ie. you cannot redefine array B to be something other than an INTEGER (as in the above example). Combining arrays is a by-product of REDIM.
    DIM A(1 to 100) AS INTEGER
    DIM B(1 to 100) AS INTEGER
    REDIM A(1 to 200) AS INTEGER   '-- Combines A and B together
    What the above code does is preserve the data in A as well as combining the array B. so index from 101 to 200 is the data for B and 1 to 100 is the data for A. Clarification: Array B has not been modified, it still maintains its own address space and will not overwrite A's data and vice versa. Note that this by-product does not apply to redimming Fixed Strings, Variants and Components.
    Redim table
      DIM Button(1 TO 2, 1 TO 2) AS QBUTTON
    REDIM Button(1 TO 2, 1 TO 4) AS QBUTTON
    Note that when dealing with multiple dimensions the elements are shifted to fill each column. So element (2,2) is actually moved to position (1,4).


    REMCommentWindows/Unix

    A BASIC declaration that allows explanatory remarks to be inserted in a program. It's suggested that you use ' to start your comments instead.

    Syntax: REM remark
    REM This is a comment, nothing is executed
    ' This is another comment



    RENAMESYSTEM StatementWindows/Unix

    A statement that renames a file. If file already exists the operation is not executed.

    Syntax: RENAME file1, file2
    RENAME "abc.txt", "xyz.txt"



    REPLACE$STRING FunctionWindows/Unix

    A function that replaces a portion of a string with another.

    Syntax: REPLACE$(source-string, replace-string, index)
    A$ = REPLACE$("Hello", "J", 1) '-- returns Jello



    REPLACESUBSTR$STRING FunctionWindows/Unix

    A function that replaces a substring with another string. All occurrences will be replaced. The length of the replacement string does not need to match the length of the replaced string.

    Syntax: REPLACESUBSTR$(source-string, replace-string, replacement-string)
    A$ = REPLACESUBSTR$("abcdefgabcdefg", "abc", "99") '-- returns 99defg99defg



    RESOURCERESOURCE FunctionWindows/Unix

    A function that returns the absolute position of the resource from the current program.

    Syntax: RESOURCE(numeric-expression)
    EXTRACTRESOURCE Resource(0), "test.bmp"

    Details:
    RESOURCE() is an array consisting of 0 to RESOURCECOUNT-1 elements. Element 0 corresponds to the first $RESOURCE handle you specify and so on. If numeric-expression is not in the range 0 to RESOURCECOUNT-1, this function returns 0.


    RESOURCECOUNTRESOURCE FunctionWindows/Unix

    A function that returns the number of resources in the current program.

    Syntax: RESOURCECOUNT
    A% = RESOURCECOUNT



    RESTOREStatementWindows/Unix

    A statement that allows DATA statements to be reread from a specified line.

    Syntax: RESTORE [{linelabel | linenumber}]
    RESTORE

    Details:
    If the argument is omitted, the next READ statement which executes will read the first item in the first DATA statement in the program. Linelabel or Linenumber identifies the DATA statement you want the next READ statement to use. The first item from that line will be read.


    REVERSE$STRING FunctionWindows/Unix

    A function that reverses (or mirrors) a string.

    Syntax: REVERSE$(string-expression)
    A$ = REVERSE$("Hello") '-- returns olleH



    RGBCONVERSION FunctionWindows/Unix

    A conversion function that takes the red, green and blue parameters and combines them to form a BGR numeric representation.

    Syntax: RGB(redvalue, greenvalue, bluevalue)
    C = RGB(255, 0, 255)

    Details:
    Values range from 0-255. Values outside this range produce undefined results.


    RIGHT$STRING FunctionWindows/Unix

    A function that returns the rightmost n characters of a string.

    Syntax: RIGHT$(string-expression, n)
    A$ = RIGHT$("Hello", 3) '-- returns llo



    RINSTRSTRING FunctionWindows/Unix

    Reverse INSTR is a function that compares 2 strings and returns the position of the find-string with respect to the search-string. Instead of starting the search from left to right, like INSTR, RINSTR searches right to left (ie. the reverse of INSTR). If found, RINSTR returns the index position of the find-string, 0 otherwise.

    Syntax: RINSTR([start,] search-string, find-string)
    A% = RINSTR("Hello World", "l") '-- returns 10
    A% = RINSTR(4, "hehe they", "he") '-- returns 3



    RMDIRSYSTEM StatementWindows/Unix

    A statement that removes a directory.

    Syntax: RMDIR directory
    RMDIR "abc"



    RNDMATH FunctionWindows/Unix

    A function that returns a random number whose sequence is generated by calling RANDOMIZE.

    Syntax: RND[(upper-bound)]
    A% = RND(10)

    Details:
    If no upper-bound is given, RND returns a decimal number in the range 0 to 1.


    ROUNDMATH FunctionWindows/Unix

    A math function that converts a number to an integer by rounding the fractional part of the expression.

    Syntax: ROUND(numeric-expression)
    A% = ROUND(3.49)   '-- Returns 3
    A% = ROUND(3.50)   '-- Returns 4



    RTRIM$STRING FunctionWindows/Unix

    A string function that returns a string with trailing spaces removed.

    Syntax: RTRIM$(string-expression)
    A$ = RTRIM$("Hello ") '-- returns Hello



    RUNSYSTEM StatementWindows/Unix

    A statement that executes a specified program without blocking.

    Syntax: RUN filespec
    RUN "rapidq.exe"



    SENDMESSAGERAPID-Q SpecificWindows

    A WinAPI call to SendMessage, blocks until message is processed.

    Syntax: SENDMESSAGE hWnd, uMsg, wParam, lParam
    SENDMESSAGE Form.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0

    Details:
    SendMessage is a WinAPI call so instead of filling this entire page with information you can look up this function in your WinAPI manual/help file.


    SGNMATH FunctionWindows/Unix

    A math function that indicates the sign of a numeric expression.

    Syntax: SGN(numeric-expression)
    A% = SGN(-123)   '-- Returns -1

    Details:
    If numeric-expression is positive, SGN returns +1.
    If numeric-expression is zero, SGN returns 0.
    If numeric-expression is negative, SGN returns -1.


    SHELLSYSTEM Statement/FunctionWindows

    SHELL can be called as a statement or as a function. It has the same functionality as RUN except that it blocks your application until the executed one has ended.

    Syntax: SHELL command
    SHELL "rapidq.exe"
    Syntax: SHELL(command, showCMD)
    PID = SHELL("rapidq.exe", SW_SHOWNORMAL)

    Details:
    If calling SHELL as a function, the return value is the process ID of the executed program, and will not block your program. showCMD can be any of the following:
    0 = SW_HIDE              6 = SW_MINIMIZE
    1 = SW_SHOWNORMAL        7 = SW_SHOWMINNOACTIVE
    2 = SW_SHOWMINIMIZED     8 = SW_SHOWNA
    3 = SW_SHOWMAXIMIZED     9 = SW_RESTORE
    4 = SW_SHOWNOACTIVATE   10 = SW_SHOWDEFAULT
    5 = SW_SHOW


    SHOWMESSAGERAPID-Q SpecificWindows/Unix

    A statement used to display a generic popup message box.

    Syntax: SHOWMESSAGE string-expression
    SHOWMESSAGE "Hello world!"



    SINMATH FunctionWindows/Unix

    A math function that returns the sine of an angle given in radians.

    Syntax: SIN(numeric-expression)
    PI = 3.14153
    C# = SIN(PI)

    Details:
    Numeric-expression is the angle expressed in radians.


    SIZEOFMEMORY FunctionWindows/Unix

    A function that returns the size, in bytes, of a data type.

    Syntax: SIZEOF(datatype|variable)
    PRINT SIZEOF(MyUDT)
    PRINT SIZEOF(MyVar)
    PRINT SIZEOF(INTEGER)

    Details:
    To calculate the size of a UDT, you must first DIM it.
    ie. DIM MyUDT AS TMyUDT


    SOUNDI/O StatementWindows

    A device I/O statement that generates sound through the PC Speaker.

    Syntax: SOUND frequency, duration
    SOUND 4000, 18

    Details:
  • Frequency is a numeric expression whose value is between 37 and 32,767. Frequency is measured in cycles/second, or hertz.
  • Duration is a numeric expression whose value is between 0 and 65,535. There are 18.2 clock ticks per second, so 18 is considered 1 second, etc...


  • SPACE$STRING FunctionWindows/Unix

    A string function that returns a string of spaces of length n.

    Syntax: SPACE$(n)
    A$ = SPACE$(5)



    SQRMATH FunctionWindows/Unix

    A math function that returns the square root of a number.

    Syntax: SQR(numeric-expression)
    A# = SQR(9) '-- returns 3



    STATICStatementWindows/Unix

    Similar to DIM, this statement names one or more variables and allocates storage space for them. However, declaring STATIC variables means that variable values are preserved between procedure calls. Note that only simple types are affected.

    Syntax: STATIC variable[(subscripts)] AS type
    STATIC A AS INTEGER, B AS BYTE, S AS STRING

    Details:
    STATIC has no affect (ie. same as using DIM) when declared in the main module. Use STATIC only inside a SUB/I or FUNCTION/I.

    Examples:
        '-- Non static count
        SUB Count (N AS INTEGER)
           DIM B AS LONG
    
           B = N
           IF N = 10 THEN EXIT SUB
           Count(N+1)
           PRINT B
        END SUB
    
        Count(1)
    
        '-- Static count, B retains the same value
        SUB StaticCount (N AS INTEGER)
           STATIC B AS LONG
    
           B = N
           IF N = 10 THEN EXIT SUB
           StaticCount(N+1)
           PRINT B
        END SUB
    
        StaticCount(1)
    


    STR$CONVERSION FunctionWindows/Unix

    A conversion function that returns a string representation of the value of a numeric expression.

    Syntax: STR$(numeric-expression)
    A$ = STR$(99)



    STRF$CONVERSION FunctionWindows

    A conversion function that returns a formatted string representation of the value of a numeric expression.

    Syntax: STRF$(numeric-expression, Format%, Precision%, Digits%)
    A$ = STRF$(99.9934, ffGeneral, 4, 4)
    A$ = STRF$(12345678, ffNumber, 8, 0)

    Details:
    Precision% specifies how many decimal places to calculate.
    The following are valid Formats:
    0 = ffGeneral      2 = ffFixed
    1 = ffExponent     3 = ffNumber
    ffGeneral converts to the shortest possible decimal string, where trailing zeros are removed. Digits% range from values of 0 to 4.
    ffExponent converts to scientific notation of the form -d.ddd...E+dddd. Digits% range from values of 0 to 4.
    ffFixed converts to fixed point format of the form -ddd.ddd... Digits% range from values of 0 to 18.
    ffNumber converts to a number format of the form -d,ddd,ddd.ddd... Where the resulting string contains thousand separators.


    STRING$STRING FunctionWindows/Unix

    A string function that returns a string whose characters all have a given ASCII code or whose characters are all the first character of a string expression.

    Syntax: STRING$(count, byte)
    A$ = STRING$(9, 65) '-- Returns AAAAAAAAA
    Syntax: STRING$(count, string-expression)
    A$ = STRING$(9, "ABC") '-- Returns AAAAAAAAA

    Details:
    The first parameter indicates the number of times to repeat the character. The second parameter can either be a string expression, whose first character is used as the repeat character, or a byte number in the range from 0 to 255 representing the ASCII character code.


    SWAPStatementWindows/Unix

    An assignment statement that exchanges the values of 2 variables.

    Syntax: SWAP variable1, variable2
    SWAP A$, B$

    Details:
    Variable1 and variable2 should be of the same type, but Rapid-Q won't complain. Also, do not swap variants using the SWAP function if their types do not match.


    TALLYSTRING FunctionWindows/Unix

    Tally counts the number of occurrences of MatchString within a SearchString.

    Syntax: TALLY(search-string, match-string)
    Count& = TALLY("abcdefghijklmnabc", "abc")   '-- returns 2



    TANMATH FunctionWindows/Unix

    A math function that returns the tangent of an angle given in radians.

    Syntax: TAN(numeric-expression)
    T# = TAN(90)

    Details:
    Numeric-expression is the angle expressed in radians.


    TIME$SYSTEM FunctionWindows/Unix

    A function that returns a string containing the current time formatted as HH:MM:SS. Where HH = hour (0-23), MM = minute (0-59) and SS = seconds (0-59)

    Syntax: TIME$
    PRINT TIME$

    Details:
    Unlike QBasic where you can set the current date using the TIME$ statement, you cannot do this under Rapid-Q.


    TIMERSYSTEM FunctionWindows/Unix

    A function that returns the number of seconds elasped since midnight.

    Syntax: TIMER
    T! = TIMER

    Details:
    Timer value for Linux/Unix is the number of seconds elasped since your program started.


    UBOUNDARRAY FunctionWindows/Unix

    A function that returns the upper bound of the array.

    Syntax: UBOUND(arrayname [,dimension])
    DIM A(-50 TO 100) AS INTEGER
    L% = UBOUND(A) '-- Returns 100

    Details:
    If the array has multiple dimensions, you can use the optional dimension argument to check the upper bound of each one.


    UCASE$STRING FunctionWindows/Unix

    A string function that returns a string expression with all letters upper-case.

    Syntax: UCASE$(string-expression)
    A$ = UCASE$("Hello") '-- returns HELLO



    UNLOADLIBRARYDLL StatementWindows

    Removes DLL from memory (only those declared in Rapid-Q). If DLL hasn't been loaded or is not found, this statement does nothing.

    Syntax: UNLOADLIBRARY(DLLName)
    DECLARE FUNCTION UpdateWindow LIB "USER32" ALIAS _
              "UpdateWindow" (hWnd AS LONG) AS LONG
    UNLOADLIBRARY("USER32") '-- Removes USER32.DLL from memory

    Details:
    It is not required that you unload a DLL, this is done for you when your Rapid-Q program ends. Unloading a DLL library from memory does not mean the function call that requires the DLL will fail. The DLL is again reloaded into memory before the function call, so you can UnLoad it again if you want. Please note that library names should match, so in your declaration for LIB "USER32" ... to unload this library, you must match that same name. UNLOADLIBRARY("USER32.DLL") does nothing, it must be "USER32" in this particular case. See also LIBRARYINST.


    VALCONVERSION FunctionWindows/Unix

    A conversion function that returns a numeric representation of the string expression.

    Syntax: VAL(string-expression)
    A = VAL("995")



    VARPTRADDRESS FunctionWindows/Unix

    A function that returns the address, ie. pointer to, of the given variable name. Variable must be a declared variable, ie. not a component variable such as QForm.Caption

    Syntax: VARPTR(variablename)
    Addr& = VARPTR(MyString$)
    Addr& = VARPTR(MyArray(0))



    VARPTR$ADDRESS FunctionWindows/Unix

    A function that returns the string representation of a given address.

    Syntax: VARPTR$(address)
    S$ = VARPTR$(279027343)



    VARTYPEVARIANT FunctionWindows/Unix

    A function that returns the data type of the current value stored in the variant.

    Syntax: VARTYPE(variant)
    DIM myvariant(100) AS VARIANT
    myvariant(1) = "G"
    VType = VARTYPE(myvariant(1))

    Details:
    Valid return values are:
    0 - Number (includes Byte, Word, Dword, Short, Long/Integer)
    1 - Float (includes Single, Double)
    2 - String
    
    All undefined variants are initialized as Numbers.




    Prev Chapter Contents Next Chapter
    掌柜推荐
     
     
     
     
     
     
     
     
     
     
     
     
    © Tue 2017-10-24  Guidance Laboratory Inc.
    Email:webmaster1g.yi.org Hits:0 Last modified:2015-12-25 19:42:28