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)
Strange Error
Re: Strange Error
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
Re: Strange Error
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:
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"
Re: Strange Error
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
Re: Strange Error
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)
Re: Strange Error
Maybe another anomaly as I am using Win 7 64 bit
Re: Strange Error
Compiles here without errors, too. I'm using Win7 with current 0.90.1 fbc and wxFBE.