QB45 to FreeBASIC Runtime Error Codes

New to FreeBASIC? Post your questions here.
Post Reply
Triopstor
Posts: 106
Joined: Apr 25, 2006 13:11

QB45 to FreeBASIC Runtime Error Codes

Post by Triopstor »

Hello

I don't understand what is wrong with the Quick Basic 4.5 code.

Code: Select all


#Lang "QB"
DECLARE SUB READ.LINK.DAT()

'LINK.DAT GLOBAL VARIABLES
COMMON SHARED TDir$, Year1$, DR$, RE$

'*** "VERIFY" GLOBAL VARIABLES ***
COMMON SHARED COL(), ROW(), V$(), D$(), I$(), R$()
COMMON SHARED SP2, SP2$, V, CLOR1, CLOR2, P, L
DIM COL(5), ROW(5), V$(5), D$(5), I$(5), R$(5, 1)

CALL READ.LINK.DAT
SLEEP: SYSTEM

ErrorHandler:
   IF ERR = 53 THEN
      CALL LINK.DAT
      RESUME
   END IF
   IF ERR = 14 THEN
      PRINT "ErrorHandler: ERROR- Out of String Space"
      SYSTEM
   ELSE
      'some other error, so print message and abort
      PRINT "ErrorHandler: Unrecoverable error--"; ERR
      'ON ERROR GOTO 0
      STOP: RESUME
   END IF

ErrorHandler2:
   IF ERR = 53 THEN
      RESUME NEXT
   END IF
   IF ERR = 14 THEN
      PRINT "ErrorHandler2: ERROR- Out of String Space"
      SYSTEM
   ELSE
      'some other error, so print message and abort
      PRINT "ErrorHandler2: Unrecoverable error--"; ERR
      'ON ERROR GOTO 0
      STOP: RESUME
   END IF
   
   
SUB LINK.DAT
'PURPOSE: TO PASS VARIABLE VALUES TO A CHAINED PROGRAM.
'PASSED VARIABLES: TRACKDIR$,DR$

'*** SET DIRECTORY TO NONE IF NOT CHOSEN YET ***
IF DR$ = "" THEN DR$ = "NONE": RACE$ = "01"

'*** OPEN FILE ***
OPEN "LINK.DAT" FOR OUTPUT LOCK WRITE AS #1
WRITE #1, TDir$, Year1$, DR$, RE$, R$(3, 1), R$(4, 1)
CLOSE #1

END SUB


SUB READ.LINK.DAT
'PURPOSE: TO READ LINK.DAT. A FILE THAT PASSES VARIABLE VALUES TO THIS
'         CHAINED PROGRAM

'*** READ FILE ***
ON ERROR GOTO ErrorHandler
OPEN "LINK.DAT" FOR INPUT LOCK WRITE AS #1
INPUT #1, TDir$, Year1$, DR$, RE$, R$(3, 1), R$(4, 1)
CLOSE #1
SHELL "Cd D:\Hre\" + TDir$ + Year1$
ON ERROR GOTO ErrorHandler2

'*** SET DIRECTORY TO NULL IF NOT CHOSEN YET ***
IF DR$ = "NONE" THEN DR$ = ""



END SUB
The concise runtime error code is:

D:\QB45\FBIDETEMP.c: In Function 'READ$LINK$DAT:
C: 154:2 LABEL$7 used but not defined
C: 138:2 LABEL$2 used but not defined

There is only 81 lines of code so I don't know what 154 and 138 mean.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: QB45 to FreeBASIC Runtime Error Codes

Post by fxm »

These errors are 'GCC' compile errors.
Compatibility of '#Lang "QB"' and 'QB error handling' with 'GCC 64-bit' compile ?
(no such errors with 'GAS 32-bit', 'GCC 32-bit', neither with 'GAS64 64-bit')
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: QB45 to FreeBASIC Runtime Error Codes

Post by SARG »

I get also the error with gcc32.

Code: Select all

FreeBASIC Compiler - Version 1.10.0 (2023-05-15), built for win64 (64bit)
Copyright (C) 2004-2023 The FreeBASIC development team.
standalone
target:       win64, x86-64, 64bit
backend:      gcc
compiling:    D:\fbdebugger\fbdebugger-New\test4.bas -o D:\fbdebugger\fbdebugger-New\test4.c (main module)
Restarting fbc ...
target:       win32, 686, 32bit
backend:      gcc
compiling:    D:\fbdebugger\fbdebugger-New\test4.bas -o D:\fbdebugger\fbdebugger-New\test4.c (main module)
compiling C:  D:\compiler108\freebasic64bit\bin\win32\gcc.exe -m32 -march=i686 -S -nostdlib -nostdinc -Wall -Wno-unused -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables -Wno-format -masm=intel "D:\fbdebugger\fbdebugger-New\test4.c" -o "D:\fbdebugger\fbdebugger-New\test4.asm"
D:\fbdebugger\fbdebugger-New\test4.c: In function 'READ$LINK$DAT':
D:\fbdebugger\fbdebugger-New\test4.c:156:2: error: label 'label$7' used but not defined
  156 |  fb_ErrorSetHandler( &&label$7 );
      |  ^~~~~~~~~~~~~~~~~~
D:\fbdebugger\fbdebugger-New\test4.c:140:2: error: label 'label$2' used but not defined
  140 |  fb_ErrorSetHandler( &&label$2 );
      |  ^~~~~~~~~~~~~~~~~~
compiling C failed: 'D:\compiler108\freebasic64bit\bin\win32\gcc.exe' terminated with exit code 1
A workaround is to put the errorhandlers inside the sub READ.LINK.DAT

Code: Select all

SUB READ.LINK.DAT
'PURPOSE: TO READ LINK.DAT. A FILE THAT PASSES VARIABLE VALUES TO THIS
'         CHAINED PROGRAM

'*** READ FILE ***
ON ERROR GOTO ErrorHandler
OPEN "LINK.DAT" FOR INPUT LOCK WRITE AS #1
INPUT #1, TDir$, Year1$, DR$, RE$, R$(3, 1), R$(4, 1)
CLOSE #1
SHELL "Cd D:\Hre\" + TDir$ + Year1$
ON ERROR GOTO ErrorHandler2

'*** SET DIRECTORY TO NULL IF NOT CHOSEN YET ***
IF DR$ = "NONE" THEN DR$ = ""

exit sub

ErrorHandler:
   IF ERR = 53 THEN
      CALL LINK.DAT
      RESUME
   END IF
   IF ERR = 14 THEN
      PRINT "ErrorHandler: ERROR- Out of String Space"
      SYSTEM
   ELSE
      'some other error, so print message and abort
      PRINT "ErrorHandler: Unrecoverable error--"; ERR
      'ON ERROR GOTO 0
      STOP: RESUME
   END IF

ErrorHandler2:
   IF ERR = 53 THEN
      RESUME NEXT
   END IF
   IF ERR = 14 THEN
      PRINT "ErrorHandler2: ERROR- Out of String Space"
      SYSTEM
   ELSE
      'some other error, so print message and abort
      PRINT "ErrorHandler2: Unrecoverable error--"; ERR
      'ON ERROR GOTO 0
      STOP: RESUME
   END IF
   

END SUB
Last edited by SARG on May 20, 2023 16:39, edited 2 times in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: QB45 to FreeBASIC Runtime Error Codes

Post by fxm »

You are right.
Errors with GCC (32 et 64 bi), GAS and GAS64 OK.
SARG
Posts: 1755
Joined: May 27, 2005 7:15
Location: FRANCE

Re: QB45 to FreeBASIC Runtime Error Codes

Post by SARG »

The problem seems due to the labels outside of the procedure so a workaround is to put them inside with the corresponding code (my first post updated).
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: QB45 to FreeBASIC Runtime Error Codes

Post by fxm »

Yes, problem already seen:

fxm wrote: Jun 03, 2022 16:24 There always are strange behaviors of 'ON ERROR GOTO label', and additionally dependent on the backend code used ('gas' or 'gcc' for example).
You above code works with 'gas' but not with 'gcc'.
For safer behavior, I recommend that the 'ON ERROR GOTO label' statement and the 'label' body be in the same scope:

See also the more general bug report:
#602 'On Local Error Goto ...' does not work as specified (+GCC)
(more precisely the second discussion item)
Triopstor
Posts: 106
Joined: Apr 25, 2006 13:11

Re: QB45 to FreeBASIC Runtime Error Codes

Post by Triopstor »

Thanks to Everyone.

I thought I was going crazy for a while. I'll download QB 4.5 on to my newest computer and compile the program in QB 4.5
Then try to shell to the .EXE program via the FreeBASIC 64 bit version I'm using.

Do 32-bit executable files work with a windows 10 operating system?
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: QB45 to FreeBASIC Runtime Error Codes

Post by srvaldez »

I think that qb45 is 16-bit and that it most likely won't run on 64-bit Windows without emulation, it might run on 32-bit Windows 10 but more sure it will run in 32-bit Windows 7 or xp
Post Reply