Advice on converting large QB45 program to FB

New to FreeBASIC? Post your questions here.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Advice on converting large QB45 program to FB

Postby dyanez » Mar 07, 2009 15:03

I have been writing programs in QB45, which I use in my personal trading activities, since the early 1990's. The consist of several modules which allow me to achieve a total exe file size of 325kb.

Because they are DOS based they cause problems when I use them in the course of the day as there is significant keystroke lag between entry and appearance on the screen.

I use these programs exclusively for myself and because I am in my late 60's and have neither the time nor desire to learn a completely new language I hoped I could port these to a BASIC variant that was Windows or Linux based without having to totally rewrite my spaghetti code, which although inelegant, does precisely what I require.

Any and all suggestions as to how I might port them to FreeBasic would be greatly appreciated.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 07, 2009 15:09

First thing would be to load your QB code into FreeBASIC. Add the line -lang qb as the first line and then see what errors you get. Post them here for specific help.

Good Luck!
-Vince
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » Mar 07, 2009 15:14

I think -lang fblite is slightly better. Try qb, then try fblite, then post the one which contains the least amount of errors.

:)

rb
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 07, 2009 15:18

Thanks, I'll try that in the next day or two anf get back. The weather has turned warm and wife insists on an outing this weekend.

Appreciate.
counting_pine
Site Admin
Posts: 6225
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Mar 08, 2009 0:07

If you could provide a brief summary of what the code does and how it does it, that will also give us some idea of where you might run into difficulties.

Lang qb is less likely to have compatibility issues, but if lang fblite works, then great: it is more like lang fb (the default dialect), and so it provides more modern features, and also the people helping you will be more familiar with it.

In any case, you can compile in a different dialect - e.g. lang qb - either by having -lang qb on the FBC command-line, or by putting '$lang: "qb" at the top of your code.

Have you had a go at writing/compiling anything in FB already, or are you just testing the waters at this point?
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Postby KristopherWindsor » Mar 08, 2009 0:39

Define "large" (in lines of code).
Because the "-lang qb" option will require you to make fewer changes to get the code compiling, but if you can get your code to work without "-lang qb," you won't regret the extra time spent.
Some of FreeBasic's features are not available with "-lang qb."
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Lines of code

Postby dyanez » Mar 08, 2009 13:15

The first module contains 1516 lines of code, there are two other large modules each in the 1500 line range and a another 3-4 with much lesser lines.

As an estimate I would say approximately 6000 lines.

Yes I have tried compliling and get syntax error messages, for example

Code: Select all

          IF file = 1 THEN
          file$ = "eur"
          name$ = "EUR"


and

Code: Select all

OPEN "c:\forex\inp\" + file$ FOR INPUT AS #1
      INPUT #1, date1, tm, tot, high, low, last, change, avgchg
   CLOSE #1


These can be easily corrected but I was trying to determine the protocol for flat file storage and retrieval.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 08, 2009 13:26

f you could provide a brief summary of what the code does and how it does it, that will also give us some idea of where you might run into difficulties.


What I use these programs for is quantitative analysis of forex prices and trends. The data computed includes exponential moving averages, frequency of occurrences and a variety of other functions. The following code clip will give you some idea of what is involved:



Code: Select all

 OPEN "c:\forex\data\" + file$ FOR INPUT AS #1
      DO UNTIL EOF(1)
      INPUT #1, date, tm, i, high, low, last, change, avgchg
        ima = .0952 * (last - ima) + ima
        sma = .3334 * (last - sma) + sma
                        IF i >= n - 4 THEN
                        chg = change
                        IF change < 0 THEN
                        chg = chg * -1
                        tchg = tchg + chg
                        ELSEIF chg >= 0 THEN
                        chg = chg
                        nchg = nchg + chg
                        END IF
                        IF tchg = 0 THEN tchg = .0001
                        END IF
                        IF i >= n - 13 THEN
                        chg = change
                        IF change < 0 THEN
                        chg = chg * -1
                        rchg = rchg + chg
                        ELSEIF chg >= 0 THEN
                        chg = chg
                        schg = schg + chg
                        END IF
                        IF rchg = 0 THEN rchg = .0001
                        END IF
                                     
                           
      f = f + 1

      PRINT USING "#####"; date;
      PRINT USING "##"; TAB(7); tm;
      PRINT USING "#####"; TAB(12); high;
      PRINT USING "#####"; TAB(19); low;
      PRINT USING "#####"; TAB(26); last;
      PRINT USING "#####"; TAB(35); change;
        rng = high - low
        vty = (rng / last) * 100
      PRINT USING "####"; TAB(45); rng;
      PRINT USING "##.##"; TAB(53); vty;
      PRINT USING "#####"; TAB(59); sma;
        IF last >= sma THEN PRINT TAB(66); "+";
        IF last < sma THEN PRINT TAB(66); "-";
      PRINT USING "#####"; TAB(70); ima;
        IF last >= ima THEN PRINT TAB(77); "+"
        IF last < ima THEN PRINT TAB(77); "-"

        prev = last
        th = high - prev
        tl = prev - low
        tth = tth + th
        hrng = (tth / f)
        ttl = ttl + tl
        lrng = (ttl / f)

      LOOP
      CLOSE #1


The second snippet gives you my present method of storage sequential, flat file data.

Code: Select all

LOCATE 23, 38: INPUT " End          "; return$
      IF return$ = "" THEN
      OPEN "c:\forex\prm\data\" + file$ FOR APPEND AS #5
      WRITE #5, date, tm, ins, inr, kys, kyr, prl, prh, last
      CLOSE #5
      END IF
         OPEN "c:\forex\rsi\data\" + file$ FOR APPEND AS #1
         WRITE #1, date, tm, high, low, last, change, srsi, lrsi, pmbi, pdif
         CLOSE #1
     
         OPEN "c:\forex\vty\" + file$ FOR OUTPUT AS #6
         WRITE #6, date, tm, high, low, last, change, rng, vty, svty, ivty
         CLOSE #6
         OPEN "c:\forex\vty\data\" + file$ FOR APPEND AS #2
         WRITE #2, date, tm, high, low, last, change, rng, vty, svty, ivty
         CLOSE #2
jevans4949
Posts: 1156
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Mar 08, 2009 15:18

One thing that sometimes causes problems is that fixed-length strings (string*) are implemented differently in FB from QB; this will particulary affect user-defined types passed between old and new programs.

If your programs only use text files, then this will probably not be a problem. There are workarounds; if you need these, post here and we will provide more details.
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » Mar 08, 2009 15:20

What's the compiler saying your error is?
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Compiler

Postby dyanez » Mar 08, 2009 20:40

Error #: 14
COMMON SHARED NAME$
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 09, 2009 0:00

What is error #14? My FB Help file show that as abnormal termination signal. Are you putting -lang qb on the compiler command line, or as your first line of code?

-Vince
McLovin
Posts: 82
Joined: Oct 21, 2008 1:15
Contact:

Postby McLovin » Mar 09, 2009 0:16

NAME is a reserved keyword in FB. Could that be causing the compiler error?

http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgName
jevans4949
Posts: 1156
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Mar 09, 2009 0:22

If it is COMMON SHARED NAME$, I'm getting:
    XXX.bas(1) error 4: Duplicated definition, found 'Name'
    Common Shared Name$

NAME is a builtin command for renaming files. FB does not allow for duplicate use of variable names, e.g. x, x$, x%, x! I'm guessing this is what is happening.

Can I suggest replaceing all NAME$ with XNAME$?
counting_pine
Site Admin
Posts: 6225
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Mar 09, 2009 5:27

lang qb shouldn't have any problem with name$. Are you sure you're using lang qb, in the latest release of FB?

The snippets you posted don't have any obvious errors in them.
Can you give the exact error messages returned?

Can you also tell us what version of FB you're using? You can find this by running "fbc -version" from the command line, or by doing "print __fb_version__" in code.
One common problem people have is using an old version of FreeBASIC, such as the one bundled with FBIde. That version was 0.15b, but the latest is 0.20.0b now.


For what it's worth, from the description of your program, it doesn't sound like it would contain anything that would cause any major compatibility issues.

Return to “Beginners”

Who is online

Users browsing this forum: Google [Bot] and 5 guests