Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some RapidQ keywords
#1
Hi!

In RapidQ

1. Command$() Array of commands received (commands are separated by spaces), first element starting at 1. The zero'th element is your application path/name

How can I get in FreeBasic runned application path/name ?

2. In RQ I use

const crlf =chr$(13)+chr$(10)' "\n\r"

In FB I can use
#define CRLF chr$(13)+chr$(10)
but can't
const crlf =chr$(13)+chr$(10)

What is wrong in last string?
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#2
RapidQ being an interpreter, a$ = abc or const a$ = abc means the same for it, but on a compiler, you usually can't do string concatenation with constants, but i may change it as chr$ will be evaluated at compile-time when using literals -- #define's do just text substitution, so they can contain anything.
Reply
#3
#define is better to use than const anyways. Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#4
Quote:RapidQ being an interpreter, a$ = abc or const a$ = abc means the same for it, but on a compiler, you usually can't do string concatenation with constants, but i may change it as chr$ will be evaluated at compile-time when using literals -- #define's do just text substitution, so they can contain anything.

Thanks!
Really there are no problem to use #define instead const, it's only a matter of compatibility and code porting (RQ->FB) .

But what about application path/name =Command$(0)?
Imho it's usefull.

Next question.
I need to load text from text file into string array.
In RapidQ I use QStringList (non visual) component.
Just
Code:
FileName$="C:\BAS\freebasic\FreeBASIC\largeTst.txt"
DIM StringList1 AS QStringList
print time$
StringList1.loadfromfile(FileName$)
print time$
print StringList1.ItemCount
print len(StringList1.text)
result
09:13:30
09:13:30
256004 (lines number)
19968222 (19MB)

How can I do it in FB?
I try to write the same function (StringList1.loadfromfile), but I can't:
1. Just to load text file into string var.
In RapidQ
text$=FileStr.ReadStr( FileStr.size)
2. To load text into array line by line
I can
...
line input #f, ln$
StringList(LineCount)=ln$
LineCount=LineCount+1
...
but I don't know dimension of array and need use two loops
Code:
do until( eof(f) )
    line input #f, ln$
    LineCount=LineCount+1
loop
reDim StringList(LineCount-1) as string
seek f, 1

do until( eof(f) )
    line input #f, ln$
    StringList(LineIdx)=ln$
    LineIdx=LineIdx+1
loop
Duration of this is ~20sec.
OMG. :o
Posiible I stupid @$$, but I don't find the solution.
I can just use
do until( eof(f) )
line input #f, ln$
[newln$=function(ln$)]
print #g ,newln$
loop
but it's more slowly then RQ (interpreter!)

How can I do it?
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#5
Code:
function DELETE$(Srcstring as string, start as long, length as long) as string
'mid$(Srcstring, start , length) = ""  'Not working!
'delete$=Srcstring
delete$=left$(Srcstring,start-1)+mid$(Srcstring,start+length)
end function

fString.inc(15) : error 18: Syntax error, found: 'string'
DELETE$ - is wrong name for function ?
function DELETE (...) as string compiled good.


Also
It's working!

function DELETE(Srcstring as string, start as long, length as long) as string
delete$=left$(Srcstring,start-1)+mid$(Srcstring,start+length)delete
end function

print delete$(a$, 9, 1)

So, really no problem, I define function as DELETE and call as DELETE$. So no changes in RQ code needed.
Just for information Smile
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#6
command$ acts the same way as QB for compatiblity with QB if you want info from it your going to have to parser the string.
Reply
#7
delete$ is already a string b/c of the $, so you can't put the "as string" on the end.
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#8
Quote:delete$ is already a string b/c of the $, so you can't put the "as string" on the end.

Yeh.. I already forgot QB.. Sad
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#9
Yeah, as in QB, if you use an suffix, you can't declare the explicit variable type.

Btw, i added command$(argc) and constant's now support string expressions too, but you can't rebuild the compiler using the old versions, due a chicken-egg problem, you will have to wait for the next release, sorry..

To load that file you could do:

Code:
option explicit

declare function loadfromfile( fname as string, linetb() as string ) as integer

    dim linearray() as string
    dim lines as integer, i as integer

    lines = loadfromfile( "test.txt", linearray() )
    
    for i = 0 to lines-1
        'print linearray(i)
    next i
    


'':::::    
function loadfromfile( fname as string, linetb() as string ) as integer
    dim f as integer
    dim lines as integer, l as integer
    
    on local error goto errhnd

    lines = 20000                                '' initial lines
    
    redim linetb(0 to lines-1) as string
    
    
    f = freefile    
    open fname for input as #f

    l = 0
    do until( eof( f ) )
           if( l >= lines ) then
               lines += lines \ 2
               redim preserve linetb(0 to lines-1) as string
           end if
           
           line input #f, linetb(l)
           l += 1
    loop
    
    close #f
    
    loadfromfile = l
    exit function
    
errhnd:
    loadfromfile = 0
end function
Reply
#10
eh? i got it to rebuild...
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)