Oxygen Basic
Programming => Problems & Solutions => Topic started by: on September 28, 2018, 12:14:54 AM
-
I don't see an option such Explicit, that allows to use the name of the enum as a namespace. This means that the member names of the enums must be unique.
Enum MyEnum
option1 = 1
option2
option3
End Enum
Enum MyEum2
option1 = 10
End Enum
print option1
print option2
print option3
In the above code, the use of option1 = 10 in the second enum causes that option1 = 1 is no longer accessible. If Explicit was available, we could use MyEnum.Option1 and MyEnum2.Option2.
And what is worse, the second option1 replaces silently the first option1, without giving an error.
-
Similar problem with constants.
const x = 10
const x = 11
print x ' prints 11
The compiler doesn't complain.
This is dangerous because it can cause hard to find bugs.
-
String equates doesn't seem to accept embedded double quotes.
$s = "Hello ""World"""
prints "Hello World"
-
Is there a way that
%n = 12345.56
won't become 12345.559999999999 ?
-
It seems that enum bit only accepts bit in lowercase. ENUM bit works, but ENUM BIT or ENUM Bit does not.
-
José,
To trap duplicate definitions:
#unique on
otherwise new definitions override older ones.
#unique may be switched on and off for any section of code.
Overriding definitions always allowed within a new scope:
#unique on
enum x
a=1,b,c
end enum
scope
enum y
a=10,b,c
end enum
print b '11
end scope
print b '2
-
I've fixed the BIT case conversion.
%n 123.45
This is deployed unconverted, but you will see it cannot be stored precisely in a float. You will need to restrict the decimal places of the float when printing:
%n 123.45
print n
single nn=n
print nn
print str(nn,2) '123.45
-
For embedded quotemarks use `
as the outer quotemark (ascii 96)
'Embedded quote marks:
$s `"Hello World"`
print s
'prints "Hello World"
-
Regarding embbedded quotes (Reply #2): I am used to do it this way:
string qu=chr(34)
'$qu=chr(34)
$s = "Hello " qu "World" qu ". And Goodbye."
print s
-
Thanks Roland. It is a workaround, but I'm currently trying to ascertain if something that doesn't works as I expect or as I would like is a bug, an oversight or my ignorance of the language.
I'm also writing a documentation page related with the questions that I'm asking.
See: https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Variables.md
I try to document a keyword and, if I have doubts, I post a question. Maybe Charles can use these pages as a draft and improve them.
-
Wow!
Great job and a productive O2 day.