Strange Error

General FreeBASIC programming questions.
Sigord
Posts: 153
Joined: Mar 14, 2013 9:54
Location: Hastings UK
Contact:

Strange Error

Postby Sigord » Apr 16, 2014 9:44

Has anyone any idea what the error below means in plain English since it does not prevent a program running OK.

Command executed:
"C:\Tools\FreeBASIC-0.90.1-win32\fbc.exe" "C:\Tools\FreeBASIC-0.90.1-win32\Old QB\t.bas"

Compiler output:
C:\Tools\FreeBASIC-0.90.1-win32\Old QB\t.bas(26) warning 14(1): Branch crossing local variable definition, to label: NTP, variable: Lt_0020

Results:
Compilation successful
Generated executable: C:\Tools\FreeBASIC-0.90.1-win32\Old QB\t.exe

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 0.90.1 (07-17-2013) for win32
OS: Windows NT 6.1 (build 7601, Service Pack 1)
fxm
Posts: 9249
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Strange Error

Postby fxm » Apr 16, 2014 11:05

Yet that sentence is clear enough!

Code: Select all

'Goto Label
Dim As Integer I = 123456789
'Label:
Print I

Code: Select all

 123456789

Code: Select all

Goto Label
Dim As Integer I = 123456789
Label:
Print I

Code: Select all

warning 14(1): Branch crossing local variable definition, to label: LABEL, variable: I

Code: Select all

 86

Code: Select all

Goto Label
Dim Shared As Integer I = 123456789
Label:
Print I

Code: Select all

 123456789
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Re: Strange Error

Postby pestery » Apr 16, 2014 12:11

In plain English, your using GoTo to skip a section of the code where you defined something with Dim.

And just to add to fxm's examples:

Code: Select all

GoTo label
'Scope ' Begin scope after GoTo
Dim As Integer I = 123456789
Print I
'End Scope ' End scope before label
label:
Print "Done"

Code: Select all

Dim As Integer I = 123456789 ' Move all the Dim statements to before the Goto statements
GoTo label
Print I
label:
Print "Done"
Sigord
Posts: 153
Joined: Mar 14, 2013 9:54
Location: Hastings UK
Contact:

Re: Strange Error

Postby Sigord » Apr 16, 2014 12:21

I should have made it clear I never need to use Dim As Integer I = 123456789 etc because I use #lang "fblite" when converting old QB to FB as below. See if you get the same error

Code: Select all

#lang "fblite"
Option Gosub
dim vwl$(5) : dim t$(505) : dim nw$(505)
file$ = "none"

more:
Screen 19 : color 0,15 : Cls : Close 
Locate 6,40 : Print "ALL FILE SCANNER" : Print
Print Tab(40);"Current File ";file$ : Print
Print tab(22);"Select any File to scan and display the readable characters."
Print Tab(22);"Then use your Editor to Copy/Paste text to other sofware."
Print : Print Tab(22);"PRESS :- 1 = Select file  2 = Open your Editor  3 = Quit"
gosub halt
If k$ = "1" then goto start
If k$ = "2" then goto ntp
End

start:
LOCATE 10,10: Input "Enter any flename "; file$
Print : Print tab(33); "Remove line feeds Y/N ?"
gosub halt : q$ = k$ : cls

dim in as string*1
open file$ for binary as #1
c = 0 : d = 0 : tx$ = "" : fA = 1
do while not eof(1)
    get #1,,in
    if in = "" then close
    k =asc(in) : d = d + 1 : ok = 0   
    if q$ = "y" or q$ = "Y" then goto ms
    if k = 9 or k = 10 or k = 13 then ok = 1
ms: if k > 31 and k < 127 then ok = 1
    if k = 127 then ok = 0
    if k = 32 then ok = 1
    if ok = 1 then tx$ = tx$ + in : c = c + 1
    'if d mod 500000 = 0 then Print " " : Print space$(30);halt$: wait
    if in = " " and len(tx$) > 100 then Print tx$ : tx$ = ""
    if CsrLin > 33 Then
        Locate 37,40 : Print "** CONTINUE Y/N ? **";
        gosub halt : If k$ = "n" or k$ = "N" then close : goto more
        Cls
    End If   
Loop   
close #1
fA = 0 : Print tx$
PRINT TAB(20);"SELECTED CHR$ = "+str$(c)+" ALL DATA = "+str$(d);" PRESS SPACEBAR TO CONTINUE"
beep
do : gosub halt : Loop until k$ = " "
Goto more

halt:
do
    k$ = Inkey$
loop until k$ <> ""
Return

ntp:
If file$ ="none" then
    Locate 18,22
    Print "No file selected Editor will not display any text"
    Sleep 2000
End if   
If file$ <> "none" then f$ = file$
sl$ = "Notepad.exe " + f$ : Shell sl$
goto more

quit:
Close
end

fxm
Posts: 9249
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Strange Error

Postby fxm » Apr 16, 2014 13:03

No error on my PC
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 0.90.1 (07-17-2013) for win32
OS: Windows XP (build 2600, Service Pack 3)
Sigord
Posts: 153
Joined: Mar 14, 2013 9:54
Location: Hastings UK
Contact:

Re: Strange Error

Postby Sigord » Apr 16, 2014 13:25

Maybe another anomaly as I am using Win 7 64 bit
MOD
Posts: 555
Joined: Jun 11, 2009 20:15

Re: Strange Error

Postby MOD » Apr 16, 2014 13:38

Compiles here without errors, too. I'm using Win7 with current 0.90.1 fbc and wxFBE.

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests