Qbasicnews.com

Full Version: Syntax and other suggestions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi!

Not critical, for RapidQ compatibility only..

1. Increment, decrement statesment

INC Statement
--------------------------------------------------------------------------------
Increments numeric variable by one, or by the amount specified.

Syntax: INC(variable [, amount])
INC(I)
INC(I, 10)
-----------------------
2. I++ j-- increment and decrement


3. INP I/O Function Windows/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.
--------------------------------------------------------------------------------
INPW I/O Function Windows/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
--------------------------------------------------------------------------------

it's possible under Win9x only/, not under WinXP


4. DEFINT var1, var2 var3
Short form of
dim as integer var1, var2 var3

also
DEFBYTE, DEFDBL, DEFDWORD, DEFINT, DEFLNG, DEFSHORT, DEFSNG, DEFSTR, DEFWORD

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

or possibility to redefine reserved keywords
as

#define defint dim as integer


WBR, Andrew
AFAIK direct access to ports is not possible from Windows,you must do it thru a driver, and this drive will have an API, so IN an OUT are not needed.

INC and DEFINT alone would give you a very limited compatibility with RapidQ. What about the GUI keywords? or the object library? You can emulate INC or that DEFINT syntax by using a couple of DEFINEs..
Quote:INC Statement
--------------------------------------------------------------------------------
Increments numeric variable by one, or by the amount specified.

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

Doing

Code:
I+=10

Is shorter... Besides, making your own INC function would be a piece of cake.
Code:
#define INC(x,i)    x += i

DIM a AS INTEGER
INC(a, 10)
There.
Code:
option nokeyword defint
define defint dim as integer
Quote:
Code:
#define INC(x,i)    x += i

DIM a AS INTEGER
INC(a, 10)
There.

Yes, but there are one problem.

In RapidQ I can use
inc x
equ x += 1

but I can't
#define inc x x += 1
becouse I need use brackets for parameter
#define inc(x) x += 1

As I know #define just substitute one text pattern by other.
In fact compiler (preprocessor) seacrh pattern1 and replace it by pattern2.
So it's possible use regexp for this searh-and-replace operations.
It's realized in many searh-and-replace utilites.

So we need to delimite one pattern from another and delimite parameters.
For example

#define inc {*} ~ {*} += 1
where ~ pattern delimiter
{ } parameter delimiters
* - regexp

In this case we can search and replace any text pattern

'------example -------------
'#define a.size len(a)

#define {*}.size ~len({*})

dim s as string
dim rrs as string
s = "123456789"
rrs="12345"

print "a.size = ";a.size;" bytes"
print "rrs.size = ";rrs.size;" bytes"
'------------------------------

It's idea only, possible not actual.
Quote:AFAIK direct access to ports is not possible from Windows,you must do it thru a driver, and this drive will have an API, so IN an OUT are not needed.

INC and DEFINT alone would give you a very limited compatibility with RapidQ. What about the GUI keywords? or the object library? You can emulate INC or that DEFINT syntax by using a couple of DEFINEs..

Well, in QBasic in DOS console (under Windows 9x) and in RapidQ in GUI application I can read\write ports. Also there are some asm instructions..
So, it can be "embedded" in FreeBasic or emulated by custom functions.
RapidQ sucks. :barf: I'd hate to see the FB namespace corrupted like that...
Quote:
Code:
option nokeyword defint
define defint dim as integer

Nice! Thank you!
Quote:RapidQ sucks. :barf: I'd hate to see the FB namespace corrupted like that...

What can I say...
RapidQ rulezz :wink:
Pages: 1 2