Constant visibility.

Just starting out? Need help? Post your questions and find answers here.
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Constant visibility.

Post by jphoarau »

Good morning,

I have a question about a problem with the visibility of variables and in my case, of a constant.

I have two windows that I write to two separate files. In file1.sb there is:

Code: Select all

IncludeFile "file2.sb"

Enumeration FormWindow
  #Window_1
EndEnumeration

OpenWindow(#Window_1, 0, 0, ww, hh, "Window1", #PB_Window_ScreenCentered | #PB_Window_TitleBar)

etc...
And in file2.sb there is:

Code: Select all

Enumeration FormWindow
  #Window_2
EndEnumeration

OpenWindow(#Window_2, 0, 0, 300, 560, "Window2", #PB_Window_ScreenCentered)

if (condition)
	SetActiveWindow(#Window_1); This is where I got the error: "Constant not found #Window_1"
EndIf
The compiler gives me an error: Constant not found #Window_1, in file2. I don't understand why the constant #Window_1 is not visible in file2 even though I have done an Include of this file in file1. Can anyone enlighten me? Thanks in advance.
hoerbie
Posts: 137
Joined: Sun Mar 17, 2019 5:51 pm
Location: DE/BY/MUC

Re: Constant visibility.

Post by hoerbie »

I think the include of file2 has to be below of the enumeration (declaration) of the constant for window 1
User avatar
Paul
Posts: 210
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Constant visibility.

Post by Paul »

hoerbie is correct, your include file creates Window2 first then you try to activate Window1 before the constant or Window has been created.
Also your enumeration is giving both Windows the exact same value so after Window1 is created, Window2 will no longer be valid.
jphoarau
Posts: 22
Joined: Thu Dec 28, 2023 4:30 am

Re: Constant visibility.

Post by jphoarau »

Thanks to you two. I will correct my code and review my logic.:)
Post Reply