[quote=90601:@Dave S]Xojo has nothing line VB Regions
and apology but pet peeve here : WASTE not WAIST
one goes in the trash, the other is where you belt goes[/quote]
Thanks. I did not understand what you said here ‘Xojo has nothing line VB Regions’. Sorry.
Dave, I think maybe he was trying to make a joke/retort about line instead of like just like you commented on waist instead of waste. But I’m confused as well…
Yes. Create a class and define public and private properties. When instantiating the class, set the properties and then work on that data with private methods inside of the class. This would be my understanding of encapsulation, in short.
I would not call this “encapsulating”, just a way to organize code and to collapse and expand it in the IDE.
One could do something similar to what you suggested, by defining a public method in a modul:
Function Region(s As String) As Boolean
Return True
End Function
And now one could write, similar to VB:
#If Region("My fancy sql stuff")
// Clear current default settings in database table listcolumns
sql = "DELETE FROM " + imDB.prefix + "listcolumns WHERE DB_GUID = '" + Me.DB_GUID + "'"
#EndIf
And in the IDE, this code can now be collapsed and expanded, just like in VB.
#endif[/quote]
Yes, which brings us back to the solution Oliver Scott-Brown has initially posted:
[code]if true then //code group name
end if[/code]
He simply adds a comment, and this is the shortest way to make code collapsible in the Xojo IDE, AND get information about what we can find inside of a collapsed section.
One important note - if you use “if true” then any variables dimmed inside this code block will be scoped local to the code block. This can be either a help or a hinderance.
dim x as integer = 34
if true then
dim y1,y2,y3,y4 as integer = 42
for x as integer = 1 to 99
next x
end if
// at this point,
// x = 34
// y1 thru y4 are not defined
Personally, I use the “if true” style sometimes when I need to define a bunch of temporary variables but I don’t want them to exist later on in the method.
[quote=90800:@Michael Diehr]One important note - if you use “if true” then any variables dimmed inside this code block will be scoped local to the code block. This can be either a help or a hinderance.
dim x as integer = 34
if true then
dim y1,y2,y3,y4 as integer = 42
for x as integer = 1 to 99
next x
end if
// at this point,
// x = 34
// y1 thru y4 are not defined
Personally, I use the “if true” style sometimes when I need to define a bunch of temporary variables but I don’t want them to exist later on in the method.[/quote]
Thanks and that is a good idea for scoping variables btw.