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

Postby dyanez » Mar 09, 2009 10:41

First, let me thank all of you who have responded. Each of the suggestions/pointers is helping.

Part of my problem stemmed from trying to use FBIde so I now am using FbEdit in its place. Another key problem was not including lang qb in my first line. Where things stand now; most of the bugs are those of context and keywords which I will work through line by line if need but through line 782 of 1500+ lines all is clicking along nicely thus far.

Thanks again all.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 09, 2009 14:29

Just a quick follow up and one more question.

I am finding most of the error issues simple to resolve as they are the result of my own spaghetti coding and minor variations in keyword usage.

I am using FbEdit now and find very useful. One thing I don't seem to be grasping is correct this bit of code



Code: Select all



FXIMBI.BAS(1844) : error 21: Type mismatch, found: 'THEN'

      IF date >= start THEN
                      ^
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » Mar 09, 2009 15:01

You will have to create a function which turns the date into an integer value so that you can compare using >=.

Otherwise you'd have to learn the FB dialect and redefine how >= is treated by the compiler.

rb
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 09, 2009 16:02

@dyanez

FB does not do >= string comparison and DATE is returning a string. You could separate the date into integer vars mt,dy,yr and then compare using those separate values.

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

Postby dyanez » Mar 09, 2009 22:29

Sorry to be a pest but this one puzzles me:




Build error(s)
C:\FreeBASIC\fbc -s gui "newprm.bas"
C:\FreeBASIC\bin\win32\ld.exe: cannot open output file newprm.exe: Permission denied

Build error(s)
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 09, 2009 22:34

dyanez wrote:Build error(s)
C:\FreeBASIC\fbc -s gui "newprm.bas"
C:\FreeBASIC\bin\win32\ld.exe: cannot open output file newprm.exe: Permission denied

Build error(s)


It looks like maybe you have a copy of your program running already. Bring up Task Manager and look for the process newprm.exe and End Task.

This can happen if your program locks up or you compile with the -s gui option but don't open a graphics screen.


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

Postby dyanez » Mar 10, 2009 19:00

Quick update: have gotten one of the programs to run (sort of) meaning I can get screen output showing my menu but the program then crashes. The resulting .exe file is 119kb. Is this part of the problem?

I also have taken several subroutines and run those with the sole problem being continuous looping of my data file input but that I am sure I can sort out.

I'll be back after working with it for a while but again a big thanks to all how have made suggestions!
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 10, 2009 19:08

The resulting .exe file is 119kb. Is this part of the problem?


Not sure how this could be a problem. Your code snippet from before did not indicate you were doing anything with pointers or memory so my first guess is that you may be exceeding an array bounds. The default compiling options do not include any error checking. Put the option -exx in your compiling command line to add error checking.

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

Postby dyanez » Mar 10, 2009 20:54

Vince - have not done a command line run as suggested yet but got an "end code -1073741819" message when I've quick run in FbEdit of FbIDE.

Two problems I am having that may be at the root have to do with looping

Code: Select all

lang=qb
CLS

VIEW PRINT
          LOCATE 13, 25: INPUT "First Date to include ", start
          CLS
DO
CLS
LOCATE 1, 35:
PRINT " View Current Dataset "
LOCATE 3, 25: PRINT " (1) EUR    (2) CHF   (3) JPY "
LOCATE 4, 25: PRINT " (4) GBP    (5) EJY    "
LOCATE 10, 25: PRINT nme$
LOCATE 11, 25: INPUT "File  ", file
          IF file = 1 THEN
          file$ = "eur"
          nme$ = "EUR"
          ELSEIF file = 3 THEN
          file$ = "jpy"
          nme$ = "JPY"
          ELSEIF file = 2 THEN
          file$ = "chf"
          nme$ = "CHF"
          ELSEIF file = 4 THEN
          file$ = "gbp"
          nme$ = "GBP"
          ELSEIF file = 5 THEN
          file$ = "ejy"
          nme$ = "EJY"
          ELSEIF file = 0 THEN
          End
          END IF
          CLS



         
LOCATE 1, 23: PRINT "      " + nme$
LOCATE 1, 1: PRINT nme$; TAB(10); "High"; TAB(19); "Low"; TAB(27); "Close"; TAB(37); "Chg"; TAB(45); "Rng"; TAB(53); "Vty"
VIEW PRINT 2 TO 23
   linestoshow% = 20
   linecount% = 0
   wanttoseeit% = true
      OPEN "c:\forex\" + file$ FOR OUTPUT AS #2
      OPEN "c:\forex\data\" + file$ FOR INPUT AS #1
      DO UNTIL EOF(1)
      INPUT #1, date, tm, i, high, low, last, change, avgchg
      IF dte >= start THEN
      PRINT USING "#####"; dte;
      PRINT USING "##"; TAB(7); tm;
      PRINT USING "#####"; TAB(12); high;
      PRINT USING "#####"; TAB(19); low;
      PRINT USING "#####"; TAB(28); last;
      PRINT USING "#####"; TAB(35); change;
        rng = high - low
        vty = (rng / last) * 100
      PRINT USING "####"; TAB(44); rng;
      PRINT USING "##.##"; TAB(52); vty
      PRINT #2, USING "#####"; dte;
      PRINT #2, USING "##"; TAB(7); tm;
      PRINT #2, USING "#####"; TAB(12); high;
      PRINT #2, USING "#####"; TAB(19); low;
      PRINT #2, USING "#####"; TAB(28); last
     
      linecount% = linecount% + 1
         IF linecount% = linestoshow% THEN
            PRINT
            INPUT reply$
            IF UCASE$(LEFT$(reply$, 1)) = "T" THEN
               wanttoseeit% = false
            END IF
            linecount% = 0
         END IF
      END IF
      LOOP
      CLOSE #1
      CLOSE #2
      loop
    [here]  LOCATE 25, 38: INPUT "Return <enter>";rn$[here]
VIEW PRINT


END


I actually used one subroutine to enter my daily data today and it worked perfectly aside from having to restart for each of the five currencies so I am pleased to be making progress and grateful for the help.

Dennis[/quote]
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Mar 10, 2009 21:44

Hmmm..The only line I can see there that would cause a runtime error (other than the OPEN statements) is the line

Code: Select all

vty = (rng / last) * 100


if last=0 that would cause a DIV/0 ERROR and I'm not sure that would crash the application.

If you could compile with the -exx option it would help alot. You can add this option even if you are using FBEdit. Under OPTIONS->BUILD OPTIONS.

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

Postby counting_pine » Mar 11, 2009 8:00

@dyanez:
"lang = qb" will just do what it looks like it would do: set a variable called 'lang' equal to a variable called 'qb', just like it would in QBASIC. That's not what you want.

Put this line at the top of your code:

Code: Select all

#lang "qb"


I'm slightly puzzled as to how you got this far without it though. Perhaps you're still using an old version of FB? If you are, that line will fail to compile.

'>=' and the like DO work on strings in FB, just as in QB (i.e. compaing them character by character until the ascii value of one is greater than the other).
Your problem may be because you had a numeric variable called "date", and FB is confusing it with the "date$" function. This shouldn't happen if you have the latest version of FB, and lang qb.

Note: If your problem with FBIde was just that it came with an old version of FB, that's not too much of a problem. You can download and install the new version of FB straight over the old one, and it should work fine.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 11, 2009 10:00

Vince - yes that will cause a crash as you pointed out but will only occur if I have input incorrect data but is not the problem in this case.

counting_pine - I am using the current V 0.20.0b version. I did make that change to #lang "qb" and now have found a number of syntax errors in some "Print Using" statements which I am in process of correcting. I think some of my earlier problems were the result of using the FbIDE bundle with the older Fb version.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 11, 2009 11:21

I've cleaned up all of the syntax coding errors and di a compile-run this morning. The net result was a 365kb .exe file that crashes after displaying the opening menu. The system error message is:

<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="FXIMBI.exe" FILTER="GRABMI_FILTER_PRIVACY">
<MATCHING_FILE NAME="FXIMBI.exe" SIZE="373248" CHECKSUM="0xE0DCBAF6" MODULE_TYPE="WIN32" PE_CHECKSUM="0x65A02" LINKER_VERSION="0x10000" LINK_DATE="03/11/2009 11:00:21" UPTO_LINK_DATE="03/11/2009 11:00:21" />
</EXE>
<EXE NAME="MSVCRT.DLL" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="msvcrt.dll" SIZE="343040" CHECKSUM="0x62160733" BIN_FILE_VERSION="7.0.2600.5512" BIN_PRODUCT_VERSION="6.1.8638.5512" PRODUCT_VERSION="7.0.2600.5512" FILE_DESCRIPTION="Windows NT CRT DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="7.0.2600.5512 (xpsp.080413-2111)" ORIGINAL_FILENAME="msvcrt.dll" INTERNAL_NAME="msvcrt.dll" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x57341" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="7.0.2600.5512" UPTO_BIN_PRODUCT_VERSION="6.1.8638.5512" LINK_DATE="04/14/2008 00:12:56" UPTO_LINK_DATE="04/14/2008 00:12:56" VER_LANGUAGE="English (United States) [0x409]" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="kernel32.dll" SIZE="989696" CHECKSUM="0x7D737C09" BIN_FILE_VERSION="5.1.2600.5512" BIN_PRODUCT_VERSION="5.1.2600.5512" PRODUCT_VERSION="5.1.2600.5512" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.1.2600.5512 (xpsp.080413-2111)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xF44A2" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.5512" UPTO_BIN_PRODUCT_VERSION="5.1.2600.5512" LINK_DATE="04/14/2008 00:11:24" UPTO_LINK_DATE="04/14/2008 00:11:24" VER_LANGUAGE="English (United States) [0x409]" />
</EXE>
</DATABASE>


Does anyone have the faintest idea what this could mean is wrong? I had similar behavior, BTW, when trying to compile exe files over 325kb in DOS as well if any individual modules were too large. Is this a similar issuein FB?
McLovin
Posts: 82
Joined: Oct 21, 2008 1:15
Contact:

Postby McLovin » Mar 11, 2009 14:18

File size is not an issue here. Your exe's can be much larger than 365K in Windows 32-bit. I have EXE's that are a couple of megs in size and there are no issues.
dyanez
Posts: 35
Joined: Mar 06, 2009 12:32
Location: Richmond VA

Postby dyanez » Mar 11, 2009 18:23

This may be my last post for a while as I've had a frustrating morning and have to get on with the business of trading.

To sum up what has happened, after stumbling around as you know from my earlier posts I had gotten to the point where I was pretty pleased with my progress. After doing some thorough checking, I found indeed the I was using an earlier version of FB, 1.8 I think as I installed it from the FBEdit bundle. In any event nothing runs so it appears I am back to square one.

That said, I think the logical thing for me to do is spend some of my free time when not trading to pickup the FB syntax, etc rather than look for a quick and dirty translation of my QB45 files. Using my text editor and FBEdit I have eliminated most if not all of the minor glitches and corrected them so I'll be soldiering on as time permits.

One final note, I have converted all of my QB45 modules to .txt files. Is this the correct thing for me to have done? If I simply tired importing files they were garbled so I assumed that was the correct route to take.

Once again many thanks for all the assistance and encouragement I've gotten, I know once I get my head around FB I will be very pleased with the results. I'll be visiting the forum if not posting to add to my knowledge base.

Bye for now, Dennis

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 2 guests