Porting from Gambas 2 to Gambas 3

This table tries to take an inventory of all incompatible changes between Gambas 2 and Gambas 3.

When the IDE project converter does an automatic conversion, it inserts a comment beginning with the string [GB2:XXXX], where XXXX is the four letters wizard identifier describing which conversion occured.

Wizard identifier Symptom Details Gambas 2 → Gambas 3
ARRD "Syntax error" on array declaration When declaring a dimensioned array you have to use the NEW keyword now.
DIM sCommand AS String[5]

Dim sCommand As New String[5]
BCOL "Unknown symbol 'BackColor'..." error The BackColor property in the Control class has been removed. Use Background instead.
MyLabel.BackColor = Color.Background

MyLabel.Background = Color.Background
BIND "Too many arguments" error with UdpSocket.Bind() The UdpSocket.Bind() method cannot take a Port argument anymore.

Use the Port property instead.
hBroadcastEvent.Bind(0)

hBroadcastEvent.Port = 0
hBroadcastEvent.Bind()
CLNG "Unknown identifier 'CLng'" error The CLng() function synonymous has been removed.

Use CLong() instead.
CLng(...)

CLong(...)
CSNG "Unknown identifier 'CSng'" error The CSng() function synonymous has been removed.

Use CSingle() instead.
CSng(...)

CSingle(...)
CFLT "Unknown identifier 'CFlt'" error The CFlt() function synonymous has been removed.

Use CFloat() instead.
CFlt(...)

CFloat(...)
DBGV "Unknown symbol 'GridView' in class 'DataBrowser'" error The gridview property of the DataBrowser control has been renamed as View.
DataBrowserLog.GridView

DataBrowserLog.View
DMRG "DrawingArea.Merge is deprecated" warning message The DrawingArea.Merge does nothing anymore. You can remove it.
MyDrawingArea.Merge = TRUE

' Nothing
DSUB SQL errors with database methods Arguments of DB.Exec() and DB.Subst() above nine now must be enclosed with {} now.
MyConnection.Exec("UPDATE devices "
  "SET name = &1, module = &2, "
  "interface = &3, address = &4, "
  "location = &5, label = &6, "
  "label2 = &7, label3 = &8, "
  "value = &9, officon = &10, "
  "onicon = &11")

MyConnection.Exec("UPDATE devices "
  "SET name = &1, module = &2, "
  "interface = &3, address = &4, "
  "location = &5, label = &6, "
  "label2 = &7, label3 = &8, "
  "value = &9, officon = &{10}, "
  "onicon = &{11}")
FCOL "Unknown symbol 'ForeColor'..." error The ForeColor property in the Control class has been removed. Use Foreground instead.
MyLabel.ForeColor = Color.Red

MyLabel.Foreground = Color.Red
FNTH "Not an object" error while using Font.Height Font.Height is now a property. The old Font.Height() method has been renamed Font.TextHeight().
Font.Height("text")

Font.TextHeight("text")
FNTW "Unknown symbol 'Width'" error while using Font.Width The Font.Width() method has been renamed Font.TextWidth().
Font.Width("text")

Font.TextWidth("text")
FRMT Unexpected spaces printed with Format$ In Gambas 3, non-used formatting characters in the Format() function are replaced with spaces, whereas they were ignored in Gambas 2.

Just use less formatting characters. Exceeding digits will be printed anyway.
Format(Number, "####")

Format(Number, "#")
IMGS "Too many arguments" error with Image.Stretch() method The Image.Stretch() method does not have its third argument anymore. Remove it.
MyImage = MyImage.Stretch(64, 64, TRUE)

MyImage = MyImage.Stretch(64, 64)
INCB "Boolean incrementation is deprecated" warning message INC Boolean or DEC Boolean isn't allowed anymore. Use Boolean = Not Boolean instead.
INC Boolean
DEC Boolean

Boolean = Not Boolean
ISTY "Type mismatch" error when using IsBoolean(), IsString(), or any Is<Type>() function The Is<Type>() functions have been completely redesigned in Gambas 3. Instead of checking the datatype of an expression, they now check if a string can be safely converted to a specific datatype with the Val() function.

Use TypeOf() to do the check instead.
IF IsBoolean(Value) THEN ...
IF IsByte(Value) THEN ...
IF IsShort(Value) THEN ...
IF IsNumber(Value) THEN ...
...

If TypeOf(Value) = gb.Boolean THEN ...
If TypeOf(Value) = gb.Byte THEN ...
If TypeOf(Value) = gb.Short THEN ...
If TypeOf(Value) <= gb.Float THEN ...
...
OPEN "Unexpected OPEN" error with the OPEN instruction The OPEN instruction syntax has changed.
OPEN sBaseDir &/ "logs" &/ sMainLogFile FOR APPEND AS #hMainLogFile

hMainLogFile = Open sBaseDir &/ "logs" &/ sMainLogFile For Append
OVER "/Class/.*Symbol* is badly overridden in class *OtherClass/" error When you reimplement a symbol in an inherited class, Gambas 3 now checks that the declaration of the symbol in the child class is compatible with the one in the parent class.

Either fix the symbol declaration in the child class, or use another name for that symbol.
' Inside a form
Private Delete As Button

' Inside a form
Private btnDelete As Button
PPRO "Missing AS" error in a property definition using the PUBLIC keyword. The PUBLIC keyword is not allowed anymore in property definitions. Property are always public.
PUBLIC PROPERTY LineColor AS Integer

Property LineColor As Integer
QUES "Unknown identifier 'xxxx?'" error All test functions ending with a question mark have been removed.

Use the synoymous function beginning with "Is" instead.
Dir?(...)
Null?(...)
Integer?(...)
...

IsDir(...)
IsNull(...)
IsInteger(...)
...
QUOT "Unknown identifier 'Quote'" error The quote and Unquote class have been removed.

Replace Quote.Shell by Shell$().
Quote.Shell("...")

Shell$("...")
SLAY "Type mismatch. Integer expected" error with the Splitter.Layout property The Splitter.Layout property now takes an array of integer instead of a string of comma-separated values.
MySplitter.Layout = "500,500"

MySplitter.Layout = [500, 500]
TEXT "gb.Text is deprecated" warning message gb.Text is deprecated and replaced by gb.IgnoreCase.
gb.Text

gb.IgnoreCase

*This incompatibility is not automatically handled by the IDE import wizard.