Oxygen Basic

Programming => Problems & Solutions => Topic started by: John on September 24, 2018, 04:26:36 PM

Title: Documentation
Post by: John on September 24, 2018, 04:26:36 PM
If a new user of Oxygen Basic were to look at and compile the examples provide in the distribution, there should be no reason one couldn't be productive with the BASIC. Waiting for professional written docs to materialize anytime soon isn't  being realistic.

Title: Re: Documentation
Post by: Aurel on September 25, 2018, 09:58:52 AM
https://www.oxygenbasic.org/forum/index.php?topic=1721.msg18550#new

Hi
May i continue with my attempt on o2 help in chm form.
Of course it is not on proffesional level but can be useful ?
Title: Re: Documentation
Post by: AlyssonR on September 26, 2018, 12:56:42 AM
Any reference material is always welcome - especially when we have senior moments and forget which dialect we're using.  :o :P
Title: Re: Documentation
Post by: Charles Pegge on September 26, 2018, 04:31:10 AM
I think good search tools are the key, rather than static documentation. Assuming we will end up with thousands of examples, (currently 1200+), programmers should be able to locate any piece of code that approximates their needs. I find I'm writing far less original code now. It's mostly copy, paste, and adapt.

Oxygen_help.chm is currently more like a dictionary than a full manual. It's contents are sourced from inf\o2keyw.dat, a database of o2 keywords with various links to included examples.
Title: Re: Documentation
Post by: John on September 26, 2018, 08:40:02 AM
My vote is we expand on Charles's Github repository breaking apart the zips to source controlled pushes and use the Github markup tools for documentation.

I'm winding down my BASIC forum activity and plan to have Script BASIC on BitBucket or Gitlab and part of a major Linux distribution by 2020.
Title: Re: Documentation
Post by: Aurel on September 26, 2018, 10:21:57 AM
Quote
Any reference material is always welcome -
Ok..
then when i get some free time i will continue in hope that should be useful  :)
Title: Re: Documentation
Post by: John on September 26, 2018, 11:02:20 AM
Every contribution to the project by the community matures the BASIC. I think you should dedicate more time toward your English speaking skills which will make your programming topics easier to swallow.

Mike and Josť are great examples of 2nd language mastering.
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 12:52:07 PM
Sorry, but without documentation you're going nowhere.

Examples are useful as a complement to the documentation, not a a substitute. Besides, there are many things whose explanation can't be found in the examples.

For example:

Code: [Select]
#include "$/inc/console.inc"
DIM n AS ULONG
n = -1
print n
waitkey

Why it prints -1 instead of 4294967295.

A bug? A feature?

If you assign -1 to a WORD variable it correctly converts it to 65535.
Title: Re: Documentation
Post by: Aurel on September 26, 2018, 01:04:35 PM
Quote
Why it prints -1 instead of 4294967295.

 ???

because is right,

n is defined as INT or UINT
so -1 is a INTEGER.... i don't see problem
Title: Re: Documentation
Post by: John on September 26, 2018, 01:16:48 PM
Asking questions is another excellent way to refine the understanding of O2.
Title: Re: Documentation
Post by: John on September 26, 2018, 01:21:32 PM
Josť,

Curious. Do you have a formal education or are you self taught?
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 01:43:30 PM
In programming, self taught. Fortunately, the first PC that I used had a manual.

I learn by practice, but I first read the documentation to know if the lamguage has everything I need. And I hate to ask questions for simple things.
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 01:59:45 PM
Another question: The compiler doesn't seem to work with unicode source code files. This means that I can't work with unicode string literals. Am I right?
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 02:33:18 PM
How do you deference a pointer?

This does not compile:

Code: [Select]
$ FileName  "test.exe"
ASCIIZ s * 260
s = "Test string"
DIM p AS ASCIIZ PTR = @s
print *p

Do you really believe that this is a good way to learn a language?

The natural reaction will be to become angry quickly and send the compiler to hell.

Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 03:53:40 PM
I have collected information about O2 native data types.

See: https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Data%20Types.md

For operators, I guess that I will have to search in the C++ documentation.
Title: Re: Documentation
Post by: John on September 26, 2018, 08:16:00 PM
Quote
print *p

Do you really believe that this is a good way to learn a language?

The natural reaction will be to become angry quickly and send the compiler to hell.

It has been my experience that Charles or one of the other forum members will respond in a timely manner. Many improvements started off as a question.
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 08:16:28 PM
I have written a markdown page documenting the operators. As the help file does not provide any useful information for them, I have needed to do some guess work. Therefore, I don't know if all the information is correct. Also better usage examples for the logical and bitwise operators are needed.

See: https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Operators.md
Title: Re: Documentation
Post by: John on September 26, 2018, 08:19:46 PM
Thanks Josť!

I love your documentation style.
Title: Re: Documentation
Post by: John on September 26, 2018, 08:34:15 PM
You should have Charles give you editing permission on the O2 Github wiki.

Check out the only issue on O2 Github. Persistence produces results.
Title: Re: Documentation
Post by: Josť Roca on September 26, 2018, 08:46:42 PM
Better create a docs folder and build there markdown pages.
Title: Re: Documentation
Post by: John on September 26, 2018, 09:29:46 PM
Charles,

I think it would be wise to give Josť the same project admin rights on the Github O2 repository as Mike has moderating the forum.
Title: Re: Documentation
Post by: Aurel on September 26, 2018, 11:45:32 PM
Jose
What this example must do?
ASCIIZ s * 260
s = "Test string"
DIM p AS ASCIIZ PTR = @s
print *p
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 12:17:47 AM
In other Basic dialect it will print the content of the string. In O2, I don't know. It apparently does not support "PTR". I would like to know how can do it in O2.
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 12:43:27 AM
This compiles, but only prints "Test str".

Code: [Select]
ASCIIZ s * 260
s = "Test string"
DIM p AS char AT STRPTR(s)
print p

This works

Code: [Select]
char s = "Test string"
DIM p AS char AT STRPTR(s)
print p

But it is not what I intended to do.

If I call a function that returns a pointer to am asciiz string, i.e. an asciiz ptr, how I can deference that pointer?
Title: Re: Documentation
Post by: Aurel on September 27, 2018, 12:50:10 AM
Yes Jose some things in 02 are little bit crazy
but this work, i often forget what is what  ::)

Code: [Select]
string s
s = "Test String"
@p = s  'adress of p hold s
print p ' show "Test String"
Title: Re: Documentation
Post by: Aurel on September 27, 2018, 12:56:49 AM
This works too..

Code: [Select]
string s
s = "Test String"
char p[10] = s  'adress of p hold s
print  p ' show "Test String"

also i think that bstring work too  :)
Title: Re: Documentation
Post by: Charles Pegge on September 27, 2018, 01:28:56 AM
Josť,

o2 retro-syntax is not perfect but here are some working variations:

Code: [Select]
DIM s AS ASCIIZ*260
'
'DIM s(260) AS ASCIIZ
'char s[260]
'
s = "Test string"
'
DIM p AS ASCIIZ PTR : @p = STRPTR s
'
'char*p=strptr s
'
'ASCIIZ p AT STRPTR s
'
print p


Commandline example:
Code: [Select]
  uses corewin
  '
  'wchar* cmdline = GetCommandLineW
  '
  'dim wchar*cmdline : @cmdline=GetCommandLineW
 
  'wchar ptr cmdline = GetCommandLineW
  '
  dim cmdline as wchar ptr
  @cmdline=GetCommandLineW
  '
  print cmdline

All string types are automatically derefereced to the char-level in an expression.

Similarly, strptr will always return the char address.
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 01:54:18 AM
Thanks, Charles. I had tried everything except @p.
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 01:58:26 AM
Using "?" for casting is also unusual to me.

print hex(?f)

I think that I will use

print hex( (int) f )

or

print hex( cast(int) f)

I don't mind to type more if it makes the code less cryptic.
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 02:26:26 AM
The char data type looks cool.

Code: [Select]
CHAR c = "Test string"
c += " - more text"
print c

It grows as if it was a dynamic null terminated string!
Title: Re: Documentation
Post by: Charles Pegge on September 27, 2018, 02:50:43 AM
but you will be overflowing into unallocated space. Allocate some more chars:

Code: [Select]
CHAR c[100] = "Test string"
c += " - more text"
print c
Title: Re: Documentation
Post by: Josť Roca on September 27, 2018, 02:55:50 AM
It was too good to be true :)
Title: Re: Documentation
Post by: Aurel on September 27, 2018, 04:43:23 AM
Quote
It was too good to be true

Yes Jose o2 in many things is excellent  :D
Title: Re: Documentation - OT
Post by: John on September 27, 2018, 08:56:16 AM
Quote
It was too good to be true.

Why no one uses SB.  :-\
Title: Re: Documentation
Post by: John on September 27, 2018, 10:35:53 PM
Josť,

The O2 docs in development on your WinPBX repository are looking good.

If Charles doesn't want to expand on his repository, I think a project repository needs to be setup for source control and documentation.

I think there should be two branches. What we have now and Charles's new self compile direction.
Title: Re: Documentation
Post by: Charles Pegge on September 27, 2018, 11:24:29 PM
The core is mostly the same, but there are a few changes like Booleans producing 1 instead of -1.
Title: Re: Documentation
Post by: Josť Roca on September 29, 2018, 02:19:23 PM
I have completed another documentation page

https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Control%20Flow.md
Title: Re: Documentation
Post by: John on September 29, 2018, 02:22:29 PM
Outstanding!

Thanks for your efforts. Obtaining your interests is like hitting the jackpot.
Title: Re: Documentation
Post by: Mike Lobanovsky on September 29, 2018, 02:35:34 PM
Thank you, Josť!
Title: Re: Documentation
Post by: John on September 29, 2018, 02:40:25 PM
Maybe it's just me but developing O2 docs on a PowerBASIC repository makes this project seem like PBLite.  :-\

I would be happy to create an O2 project repository and make Charles and Josť administrators.

If we had a source control repository maybe Charles could acquire some help rather than only accepting example results of his efforts.
Title: Re: Documentation
Post by: Josť Roca on September 29, 2018, 02:54:06 PM
They're simply draft pages.  They can be copied, revised and updated later in an O2 repository. Meanwhile, I have to keep them somewhere.
Title: Re: Documentation
Post by: John on September 29, 2018, 04:18:39 PM
Agreed.

My point is we need to get source control going. Zips on a Github repository isn't its purpose.

I think Gitlab has a server version that would allow O2 a private repository with markup docs if that would solve the private ownership concerns.
Title: Re: Documentation
Post by: Charles Pegge on September 29, 2018, 10:02:27 PM

Many thanks, Josť. That is very clear documentation, and the style is attractive.

But one point I need to make is that o2 has case-sensitive modes to cope with C-headers, like gl.h. If we use #case capital, then fully capitalised keywords will not be recognised.
Title: Re: Documentation
Post by: Josť Roca on September 30, 2018, 02:46:18 AM
Then I will have to change everything to lowercase. I'm not certainly the best suited to write O2 documentation, because I still don't fully know the language (I'm learning it while I try to write the documentation), and English is no my mother language, but somebody has to do something about it. If I'm having problems, imagine a beginner...

And what "case capital" does?


Title: Re: Documentation
Post by: Charles Pegge on September 30, 2018, 03:34:22 AM
There are 3 #cases:

#case insensitive  'converts words to lowercase 'default

#case sensitive  'no case conversion 'like C etc

#case capital  'convert to lowercase, except for all-uppercase words

C headers often have all-uppercase equates or types with the same spelling as some of their procedure names. And we have to maintain that distinction in order to use such headers unmodified.
Title: Re: Documentation
Post by: John on September 30, 2018, 08:32:17 AM
Quote
I'm not certainly the best suited to write O2 documentation, ...

If we are ever to see a released O2 BASIC compiler with usable docs, don't give up now. All we need first is a good draft and you have surpassed that with your efforts.
Title: Re: Documentation
Post by: John on September 30, 2018, 09:56:06 PM
I have added a link to Josť Roca's O2 documentation project under the wizard.
Title: Re: Documentation
Post by: Josť Roca on October 01, 2018, 10:31:01 AM
I won't go so fast. If I asked for documentation it was because I wanted to know if the language had all I need for my projects, and I'm sorry to say that it does not.
Title: Re: Documentation
Post by: John on October 01, 2018, 10:42:11 AM
Can you start a wishlist so Charles knows what are the important features that are missing?
Title: Re: Documentation
Post by: Josť Roca on October 01, 2018, 11:59:28 AM
See this thread: https://www.oxygenbasic.org/forum/index.php?topic=1755.0

and also: https://www.oxygenbasic.org/forum/index.php?topic=1761.msg19141;topicseen#msg19141

The implementation of overloading operators as macros may be efficient, but doesn't suit my needs.

With Free Basic I can easily implement data types not natively supported by the compiler that behave as if they were native. With O2, I can't. Higher level support from the compiler is needed.

Imagine that each time that you use a string or a number you had to allocate them with new and then free them with del.
Title: Re: Documentation
Post by: John on October 01, 2018, 12:13:45 PM
It would be great if Charles could add compatibility features for PB and FB as a compiler switch but still keep on the path he is headed.
Title: Re: Documentation
Post by: Aurel on October 01, 2018, 01:10:44 PM
Quote
With Free Basic I can easily implement data types not natively supported by the compiler

It sounds interesting but i doubt that is useful for me.
Jose ... is FB as such have POINTER type built in like EB/IWB have?
Title: Re: Documentation
Post by: Josť Roca on October 01, 2018, 01:35:55 PM
You can use ANY PTR.
Title: Re: Documentation
Post by: John on October 02, 2018, 02:54:09 AM
I understand that O2 currently doesn't fit the mold you were hoping for.  Wouldn't this be motivation to create a set of includes for O2 as a compatibility layer?
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 04:24:57 AM
How can I write with O2 a class to add support for Variants that allows me to do this?

Code: [Select]
#INCLUDE ONCE "Afx/CVAR.inc"

FUNCTION Foo (BYREF cv AS CVAR) AS CVAR
   RETURN cv & " Third string"
END FUNCTION

SUB Foo2 (BYVAL v AS VARIANT)
   PRINT AfxVarToStr(v)
END SUB

SUB Foo3 (BYVAL v AS VARIANT PTR)
   PRINT AfxVarToStr(v)
END SUB

SUB Foo4 (BYREF ws AS WSTRING)
   PRINT ws
END SUB

' We can use CVAR with the intrinsic FB operators or with overloaded operators
DIM cv AS CVAR = "Test string"
cv = cv & " Second string"
PRINT cv

PRINT Foo(cv)

' Thanks to the overloaded CAST operator we can pass them transparently
' to procedures that expect another data type
Foo2(cv)
Foo3(cv)
Foo4(cv)

' We can assign to them any data type
DIM cv2 AS CVAR = 12345.67
print cv2

' We can also have arrays of CVar:

DIM rg(1 TO 2) AS CVAR
rg(1) = "string"
rg(2) = 12345.12
print rg(1)
print rg(2)

' And even dynamic arrays of CVar in UDTs:

TYPE MyType
  rg(ANY) AS CVAR
END TYPE

DIM t AS MyType
REDIM t.rg(1 TO 2) AS CVAR
PRINT LBOUND(t.rg)
PRINT UBOUND(t.rg)

t.rg(1) = "String"
t.rg(2) = 12345.12

print t.rg(1)
print t.rg(2)

PRINT
PRINT "Press any key..."
SLEEP

and they are garbage collected.
Title: Re: Documentation
Post by: John on October 02, 2018, 04:30:43 AM
Just when I thought we lost you in the fog you come back as a lighthouse. Your stubborn but brilliant.  8)
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 06:09:01 AM
I can build walls if I have cement and bricks.

First I wrote classes to implement data types not natively supported by FB.

Then, thanks to the flexibility provided by CVAR (Variants) I could write classes such CDispInvoke, to support COM Automation:

Code: [Select]
' // Create an instance of the RegExp object
DIM pDisp AS CDispInvoke = "VBScript.RegExp"

' // Set some properties
pDisp.Put("Pattern") = ".is"
pDisp.Put("IgnoreCase") = VARIANT_TRUE
pDisp.Put("Global") = VARIANT_TRUE

' // Execute a search
DIM pMatches AS CDispInvoke = pDisp.Invoke("Execute", "IS1 is2 IS3 is4")
' // Parse the collection of matches
IF pMatches.DispPtr THEN
   ' // Get the number of matches
   DIM nCount AS LONG = VAL(pMatches.Get("Count"))
   FOR i AS LONG = 0 TO nCount -1
      DIM pMatch AS CDIspInvoke = pMatches.Get("Item", i)
      print pMatch.Get("Value")
   NEXT
END IF

Without the funky syntaxes used by other wrappers.

It works with any COM server that returns an IDispatch pointer, for example with WMI:

Code: [Select]
' // Connect with WMI in the local computer and get the properties of the specified printer
DIM pDisp AS CDispInvoke = CWmiServices( _
   $"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2:" & _
   "Win32_Printer.DeviceID='OKI B410'").ServicesObj

' // Set the printer as the default printer
pDisp.Invoke("SetDefaultPrinter")

As I don't like Automation, I have classes for the servers that I'm more interested, e.g. ADO, Regular Expressions, Web Browser, Dictionary Object, WMI, but I always can use CDispInvoke if I need to use an Automation COM server for which I have not written wrappers or that don't have a dual interface.

If FB doesn't fully support unicode with files, no problem: I wrote several classes to work with unicode with both binary and text files.

See the documentation for the WinFBX framework (yes, I not only write it, but I also document it): https://github.com/JoseRoca/WinFBX/tree/master/docs

The problem is that I can't do the same with O2.

If the goal of O2 is to have an efficient compiler to work with OpenGL and assembler, that's fine with me, but it is not what I need.
Title: Re: Documentation
Post by: John on October 02, 2018, 06:16:37 AM
Charles is already on the v-table COM bandwagon with the work done for DLLC. Variants are the missing link.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 06:21:02 AM
I hope that Charles will understand what I mean, because you have no clue. Sorry.
Title: Re: Documentation
Post by: John on October 02, 2018, 06:26:59 AM
Even a blind pig can find food in the mud.
Title: Re: Documentation
Post by: Aurel on October 02, 2018, 08:02:57 AM
Quote
I hope that Charles will understand what I mean, because you have no clue

Jose..
I can easy say for myself that i don't have a clue about the things you present here .
Well i don't create such a type of programs But from a small mind perspective such is mine  :D
i don't care to much about that.
Anyway ...this VARIANTS are what .... POINTER type built in language ..RIGHT?
because i don't see what else might be. ::)
And also i think that some things can work in o2 in a little bit different way probably not all.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 08:04:52 AM
I'm talking of a completely different thing and you reply with "Charles is already on the v-table COM bandwagon with the work done for DLLC."

You still don't know that O2 has vtable support from many years ago?

What do you think that this sapi demo that comes with the compiler uses?

Code: [Select]
  uses com\voice

  dim as GUID          VoiceObjGuid, ISpVoiceGuid
  dim as HRESULT       hr
  dim as ISpVoice *    voice
  dim as LPUNKNOWN     pUnkOuter


  guidval VoiceObjGuid, "96749377-3391-11D2-9EE3-00C04F797396"
  guidval ISpVoiceGuid, "6C44DF74-72B9-4992-A1EC-EF996E0422D4"

  @ pUnkouter=0

  CoInitialize null

  hr=CoCreateInstance VoiceObjGuid, pUnkouter, context, ISpVoiceGuid, voice

  if hr then print "SAPI Error " hex(hr) : CoUninitialize()
  bstring2 s="Hello Everyone!"

  voice.Speak s,0,null
  voice.WaitUntilDone 0xFFFFFFFF
  voice.Release : @ voice=0

  CoUninitialize()

What I'm talking about has not any relation with vtables and COM, but about creating objects that are garbage collected.

Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 08:14:10 AM
Imagine that instead of using

Code: [Select]
pDisp.Put("Pattern") = ".is"

I have to use something like

Code: [Select]
dim v1 AS VARIANT
v1.vt = VT_BSTR
v1.bstrVal = SysAllocString("Pattern")

dim v2 AS VARIANT
v2.vt = VT_BSTR
v2.bstrVal = SysAllocString(".is")

pDisp.Put(v1, v2)

VariantClear @v1
VariantClear @v2

I have seen ansi C programmers working this way, but I'm not as masochistic as they are.
Title: Re: Documentation
Post by: Charles Pegge on October 02, 2018, 09:24:53 AM
Thanks for the additional details, Josť,

Now I have a clearer picture of what is required. I've been through a few schemes for implementing higher operations and eventually came up with the macro system, solving the performance-problem, and was coherent though a little funky on the syntax.

But this is a sketch for object-based operations:

Operations using accumulators which are transient objects, with optional destructors, and polymorphic constructors, so you can mix your types within the expression.

Code: [Select]
class tt
========
  '
  double x,y
  '
  'operations are identified as methods with the name in "" quotes
  '
  'they use 'this' as the accumulator
  '
  'the accum is auomatically created before the operator is called
  '
  'its destructor is invoked when the expression is complete
  '
  'operations return a pointer to 'this' accumulator
  '
  method destructor()
    ...
  end method
  '
  method constructor()
  x=0 : y=0
  end method
  '
  method constructor(tt*a)
  x=a.x : y=a.y
  end method
  '
  method constructor(double ax,ay)
  x=ax : y=ay
  end method
  '
  method construcor(string ax,ay)
  x=val(ax) : y=val(ay)
  end method
  '
  method "save" (tt*a)
  a.destructor
  copy @tt,@this,sizeof this
  end method
  '
  method "save" (abc*a) 'another type
  a.destructor 'if destructor exists
  copy @tt,@this,sizeof this
  end method
  '
  method "+" (tt*a)
  x+=a.x
  y+=a.y
  end method
  '
end class

internal logistics:
===================
'op     operator
'typ    class of operation
'acc    accumulator
'v      operand expression
'saved  flag
if typ has constructors
  if op=0 'load
    typ acc
    acc.constructor()
    clear saved flag
  elseif op=2 'save
    acc."save"(v) 'using polymorphic saves
    set saved flag
    goto done
  end if
  if typeof(v)<>typeof(acc)
    typ b
    b.constructor(v) 'using polymorphic constructors
    acc.op(b)
    if destructor exists then b.destructor
  else
    acc.op(v)
  end if
  '
  done:
  '
  if not saved then
    if destructor exists then acc.destructor
  else
    if destructor exists then log v to local/global destructors
    if typeof(v)<>typeof(acc)
      if destructor exists then acc.destructor
  end if
elseif typ is general udt
  use macro system
elseif typ is primitive
  use primite expression evaluation
end if



Title: Re: Documentation
Post by: John on October 02, 2018, 10:47:03 AM
Quote
You still don't know that O2 has vtable support from many years ago?

Charles made his DLLC COM functionality available to O2 users in a generic form at the same time. Much of O2's magic is users like me an you asking the Wizard to conjure a fix.

Sorry I missed your point. The VARIANT word got me excited and had tunnel vision.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 02:36:33 PM
With Free Basic, the constructor is always called. The default constructor has no parameters. Which constructor is called depends of the type of the parameter(s), if any, that you pass when you create an instance of the class. You can create an instance of the class with DIM or NEW.

If you use NEW, what you get is a pointer to the class:

DIM pObj AS MyClass PTR = NEW (<parameters>)

Being a pointer, you have to use the pointer syntax (->) with Free Basic:

<result> = pObj-><method name> (<parameters)

And free it with DEL, i.e, DEL pObj

With DIM, whitout NEW

DIM pObj AS MyClass   ' default constructor
--or--
DIM pObj AS MyClass = <parameter>   ' if there is only a parameter
--or--
DIM pObj AS MyClass = MyClass(<parameters>)   ' if there are more than one parameter

You use the dotted syntax:

pObj.<method name>(<parameters>)

The object will destroy itself and call the destructor when it goes out of scope.

You can wrap it between SCOPE/END SCOPE if you want:

SCOPE
   DIM pObj AS MyClass
   pObj.<method name>
END SCOPE

and it will be destroyed as soon as the SCOPE block ends.

FUNCTION = needs of a copy constructor. Free Basic uses the overloaded operator LET (=).

OPERATOR LET (parameter)

This allows to return a copy of the class before it is destroyed.

FUNCTION Foo () AS MyClass
   DIM pObj AS MyClass
   ....
   FUNCTION = pObj
   ....
END FUNCTION

or, if you have a constructor that accepts, lets say, an string:

FUNCTION Foo () AS MyClass
   DIM s AS STRING2
   ....
   FUNCTION = s
   ....
END FUNCTION

It creates a temporary instance of the class and calls the LET operator to allow you to make a copy of the local string, that will be destroyed when the method ends.

RETURN also creates a temporary instance of the class, but instead of LET, it calls the appropriate constructor.

FUNCTION Foo () AS MyClass
   DIM s AS STRING2
   ....
   RETURN s
END FUNCTION

What you use depends of what you are going to return. STRING2 is garbage collected, so we don't need to worry to free it. But if we want to return a data type that we have to free, for example a VARIANT, if we use RETURN then VARIANT won't be cleared. Therefore, we can use:

FUNCTION Foo () AS MyClass
   DIM v AS VARIANT
   ....
   FUNCTION = v
   VariantClear @v
END FUNCTION

Hope this helps.

I have used classes (in FB they are called TYPE) extensively, and my WinFBX framework has many of them that you can browse to see how they work.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 02:46:15 PM
With Free Basic, I almost never use NEW.

For example, I have written GDI+ classes that provide the same functionality that the C++ GDI+ classes. This makes very easy to translate C++ GDI+ examples.

Code: [Select]
' ========================================================================================
' The following example creates a SolidBrush object, clones it, and then uses the clone
' to fill a rectangle.
' ========================================================================================
SUB Example_CloneBrush (BYVAL hdc AS HDC)

   ' // Create a graphics object from the window device context
   DIM graphics AS CGpGraphics = hdc
   ' // Get the DPI scaling ratio
   DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
   ' // Set the scale transform
   graphics.ScaleTransform(rxRatio, rxRatio)

   ' // Create a SolidBrush object
   DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 255, 0, 0)

   ' // Create a clone of solidBrush
   DIM cloneBrush AS CGpSolidBrush
   solidBrush.Clone(@cloneBrush)
   ' // You can also use:
   ' DIM cloneBrush AS CGpSolidBrush = @solidBrush

   ' // Use cloneBrush to fill a rectangle
   graphics.FillRectangle(@cloneBrush, 0, 0, 100, 100)

END SUB
' ========================================================================================

I have added my "little touch" to make it DPI aware:

Code: [Select]
   ' // Get the DPI scaling ratio
   DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
   ' // Set the scale transform
   graphics.ScaleTransform(rxRatio, rxRatio)

As you can see, I don't have to worry about freeing objects. They free themselves when they go out of scope.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 02:52:41 PM
Of course, Free Basic TYPEs aren't the same that O2 classes. I'm only explaining how to use them and what you can do with them.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 02:58:28 PM
> Charles made his DLLC COM functionality available to O2 users in a generic form at the same time.

O2 users only may need to use DLCC to work with COM Automation, but if O2 classes worked like the Free Basic ones, I could write a class like my FB's CDispInvoke that is much more flexible and easy to use, and doesn't need an external DLL.

Anyway, most "decent" COM Automation servers (Office applications excluded) have dual interfaces, so you can use them with O2 without DLCC.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 03:13:34 PM
Overloaded operators in Free Basic can be privative of the class, e.g.

Code: [Select]
OPERATOR CVar.+= (BYREF cv AS CVAR)
   IF vd.vt = VT_BSTR AND cv.vd.vt = VT_BSTR THEN
      ' // Both values are strings, so concatenate
      VarCat(@vd, @cv.vd, @vd)
   ELSE
      ' // Add
      DIM vRes AS VARIANT
      IF VarAdd(@vd, @cv.vd, @vRes) = S_OK THEN VariantCopy(@vd, @vRes)
   END IF
END OPERATOR

Notice the use of the name of the class "CVar", followed by a "." and the simbol of the operator (+=).

Or global operators:

Code: [Select]
' ========================================================================================
OPERATOR & (BYREF cv1 AS CVAR, BYREF cv2 AS CVAR) AS CVAR
   DIM cvRes AS CVAR
   VarCat(@cv1.vd, @cv2.vd, cvRes.vptr)
   OPERATOR = cvRes
END OPERATOR
' ========================================================================================
Title: Re: Documentation
Post by: John on October 02, 2018, 03:21:58 PM
DLLC is a Script BASIC extension module written in O2. SB extension modules are DLLs but only callable from SB.
Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 03:27:20 PM
Notice that in all cases, the value returned is a temporary instance of the class, not a pointer to an existing one, that will destroy itself.

If you use:

DIM cv1 AS CVAR = "String"
DIM cv2 aS CVAR = "12345"
DIM cvRes AS CVAR = cv1 & cv2

It will concatenate the two variants and return a temporary instance of CVAR that will self destroy after the assignent is made.

If instead of two CVAR variables, you use another data type allowed by the constructors, e.g.

DIM cvRes AS CVAR = "Test string " & 12345

Two additional temporary instances of the class will be created by the compiler to convert the passed parameters to CVAR and destroyed when the method ends.

Title: Re: Documentation
Post by: Josť Roca on October 02, 2018, 03:37:13 PM
When speed/efficiency is wanted/needed, we can write methods like this one:

Code: [Select]
' ========================================================================================
' Attaches a variant to this class. The source variant is marked as empty.
' ========================================================================================
FUNCTION CVar.Attach (BYVAL pvar AS VARIANT PTR) AS HRESULT
   IF pvar = NULL THEN RETURN E_INVALIDARG
   VariantClear @vd
   ' // Copy the contents and give control to CVar
   DIM pdest AS ANY PTR = memcpy(@vd, pvar, SIZEOF(VARIANT))
   IF pdest = NULL THEN RETURN E_FAIL
   ' // Mark the source variant as VT_EMPTY instead of clearing it with VariantClear
   ' // because we aren't making a duplicate of the contents, but transfering ownership.
   pvar->vt = VT_EMPTY
   RETURN S_OK
END FUNCTION
' ========================================================================================
Title: Re: Documentation
Post by: John on October 02, 2018, 04:03:07 PM
Charles,

For us non-COM gurus, Eros posted a great reference.

COM in plain C (https://www.codeproject.com/Articles/13601/COM-in-plain-C)

Josť,

Do you know if VB6 OCX.DLL's provide a dual interface by default or do I need to embed the typelib via a utility?
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 02:06:48 AM
Sorry, John, but I never have used VB6.
Title: Re: Documentation
Post by: John on October 03, 2018, 03:41:09 AM
That's like never experiencing sex.  :)

Quote from: Eros
if you start getting it ... it will open a great new world. It takes some time.
With iDispatch variables I will try to make COM Automation as easy as I can.

My hero!   8)
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 05:05:49 AM
I don't see how that might benefit you.
Title: Re: Documentation
Post by: John on October 03, 2018, 05:10:22 AM
I guess you haven't been following my VB6 OCX DLL Forms project? With Eros's interest in COM/OLE automation, you now have two mature scripting languages going the same direction.
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 05:36:49 AM
I doubt that Eros will be interested in using VB6 OCX DLL Forms. I think that you're going to have a new disappointment.
Title: Re: Documentation
Post by: John on October 03, 2018, 05:40:20 AM
I doubt that Eros will be interested in using VB6 OCX DLL Forms. I think that you're going to have a new disappointment.

Are you willing to put some money behind your bet?
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 05:43:07 AM
I have said I think, not I bet. Anyway, I don't care.
Title: Re: Documentation
Post by: John on October 03, 2018, 05:48:59 AM
Quote
I don't care

That's a hit but it doesn't sink the ship.
Title: Re: Documentation
Post by: Charles Pegge on October 03, 2018, 07:56:10 AM

Thank for your further details, Josť.

In FreeBasic, how would you handle the constructors of arrays of objects?
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 08:17:31 AM
I would need to have a dynamic instance array, eg.

m_rg (any) as <object type>

redim it according the number of elements of the passed array and copy them.

In Free Basic you can pass the array using <name of the array>() and get the number of elements with lbound and ubound, or you can pass a pointer to the first element and the number of elements.
Title: Re: Documentation
Post by: John on October 03, 2018, 05:33:58 PM
The docs are looking great. Nice job!
Title: Re: Documentation
Post by: Josť Roca on October 03, 2018, 07:21:51 PM
I have added more "literature" to the bitwise operators taken from Wikipedia.
Title: Re: Documentation
Post by: John on October 03, 2018, 07:52:10 PM
I can't wait to see  Josť Roca INCLUDE files tailored for Oxygen Basic.

I see your documentation effort as putting Charles to the test.

A. Is the compiler usable?

B. Will my suggestions and bug discoveries be addressed promptly?

C. Will I have better luck with my includes within the O2 community?


Title: Re: Documentation - data types
Post by: Arnold on October 04, 2018, 04:05:12 AM
Hi Charles,

when reading the documentation of Josť about data types I came across the number ranges of float/single, doubles and extended. Is there a way to find out the minimum and maximum representation of e.g. floats/singles which are 4 bytes in size?

As I do not understand the IEEE-754 standard, I searched in Internet for the ranges and found this:

Floating Point Primitive Data Types
Type           Size            Range                           Accuracy
float           32 bits    -3.4E+38 to +3.4E+38        about 7 decimal digits
double       64 bits    -1.7E+308 to +1.7E+308        about 16 decimal digits

I also found a floating point converter:
https://www.h-schmidt.net/FloatConverter/IEEE754.html

Attached are two images where I filled out the binary input fields. I do not know the difference of (not) filling the rightmost binary field.

Could I use \examples\Diagnostics\RegSnapShot.o2bas somehow to find the values? Although I have not understood the underlying theory to calculate floating point, it would be interesting to see if the calculations of O2 are similiar.

Roland


Title: Re: Documentation
Post by: Charles Pegge on October 04, 2018, 07:18:31 AM
Hi Roland,

This is an easy way to study floating-point bits: (using an int overlay)

Code: [Select]
float f=123.45
int i at @f
print hex(i,8)

the significand is in bits 0..22 (23bits)
the exponent is in bits 23..30 (8bits)
the sign is in bit 31

You can also find out what an infinity looks like (1/0) :)
Title: Re: Documentation
Post by: John on October 04, 2018, 08:52:56 AM
Script BASIC has a couple of built-in functions to give you the MAXINT and MININT ranges. It would be nice to have a set of functions that would do the same for REAL (double) ranges.

Code: Script BASIC
  1. PRINT MAXINT,"\n"
  2. PRINT MININT,"\n"
  3.  
  4. PRINT (1/0),"\n"
  5.  


jrs@jrs-laptop:~/sb/examples/test$ scriba range.sb
9223372036854775807
-9223372036854775808
undef
jrs@jrs-laptop:~/sb/examples/test$



Charles example to view infinity just returns a undef in SB.  :(

Title: Re: Documentation
Post by: Mike Lobanovsky on October 04, 2018, 09:13:56 AM
... MAXINT and MININT ranges.
........
9223372036854775807
-9223372036854775808

Those are 64-bit values. The functions only reflect the capabilities of the operating system SB is currently running on but not the capabilities of SB proper. AFAIK SB is only capable of 32-bit integer calc on both 32- and 64-bit platforms, alas.
Title: Re: Documentation
Post by: John on October 04, 2018, 09:35:41 AM
... MAXINT and MININT ranges.
........
9223372036854775807
-9223372036854775808

Those are 64-bit values. The functions only reflect the capabilities of the operating system SB is currently running on but not the capabilities of SB proper. AFAIK SB is only capable of 32-bit integer calc on both 32- and 64-bit platforms, alas.

Code: Script BASIC
  1. PRINT FORMAT("%i",9000000000000000000 - 10), "\n"
  2.  


jrs@jrs-laptop:~/sb/examples/test$ scriba intmath.sb
8999999999999999990
jrs@jrs-laptop:~/sb/examples/test$


If that's the case my example shouldn't be working. SB has some issues with 64 bit PRINT / FORMAT and REAL. A couple other functions might need work for 64 bit.


Title: Re: Documentation
Post by: Arnold on October 04, 2018, 10:25:14 AM
Thank you, Charles. Using the float/int approach I can find the expected 23/8/1 values:

 3.4028234663852886E+38   hex: 7F7FFFFF
-3.4028234663852886E+38   hex: FFFFFFFF FF7FFFFF

Using the double/quad approach I can also find the expected 52/11/1 values:

 1.7976931348623157E+308   hex: 7FEFFFFFFFFFFFFF
-1.7976931348623157E+308   hex: FFEFFFFFFFFFFFFF

I suppose to get the values for the extended type is not so easy?

Roland
Title: Re: Documentation
Post by: Charles Pegge on October 04, 2018, 12:19:34 PM
You'll need three ints to span the extended float:

these have:
64 bits significand
15 bits exponent
1 sign bit

Code: [Select]
extended f=123.45
int i at @f
string fmt(int v){ return right(hex(v,8),8) }
print fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1])

https://en.wikipedia.org/wiki/Extended_precision
Title: Re: Documentation
Post by: Mike Lobanovsky on October 04, 2018, 12:43:59 PM
Code: [Select]
PRINT FORMAT("%i",9000000000000000000 - 10), "\n"


jrs@jrs-laptop:~/sb/examples/test$ scriba intmath.sb
8999999999999999990
jrs@jrs-laptop:~/sb/examples/test$


Oh.

That should be 64-bit Linux, I presume. My bad.
Title: Re: Documentation
Post by: John on October 04, 2018, 06:11:14 PM
You were correct about Windows. (32/64 bit)  I gave it a try on Script BASIC 64 bit Windows and it only shows MAXINT and MININT to be 32 bit values.

Code: Script BASIC
  1. PRINT MAXINT,"\n"
  2. PRINT MININT,"\n"
  3.  

(https://allbasic.info/picture_library/INT64.png)

For me, SB on Windows is a 32 bit solution. I don't have the time or desire to extend types and masks for 64 bit to work. SB Linux only has a couple minor issues under 64 bit.
Title: Re: Documentation - extended data type
Post by: Arnold on October 05, 2018, 02:13:14 PM
Hi Charles,

your formulas are suitable for developing a small floating point converter.

Looking for the maximum and minimum values of the extended type I finally found: 1.18973149535723176502e4932 which can be calculated with 2^16384. But I also found the LDBL_MIN constant which indicates the minimum positive value: 3.36210314311209350626e-4932. This can be calculated with 2^-16382 or 1/(2^16382). This seems not to work in Oxygenbasic. Is there still another way to calculate with a negative exponent?

Roland

Code: [Select]
$ filename "Ext_limits.exe"

'uses rtl32
'uses rtl64

uses console

string fmt(int v){ return right(hex(v,8),8) }

'extended f=1.18973149535723176502e4932   'LDBL_MAX
extended f=2^16384

int i at @f
printl f ",  hex: " fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1])

'f=-1.18973149535723176502e4932
f=-(2^16384)
printl f ", hex: " fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1]) & cr

'f=3.36210314311209350626e-4932           'LDBL_MIN  - min positive value
f=2^-16382
'f=1/(2^16382)
'f=pow(2,-16382)
printl f
printl fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1]) & cr

printl "Enter ... " : waitkey
Title: Re: Documentation
Post by: John on October 05, 2018, 04:33:39 PM
Josť,

Do you think it will be easier to port your includes to O2 then what it took to go to FreeBasic?
Title: Re: Documentation
Post by: Josť Roca on October 05, 2018, 04:45:06 PM
Absolutely not. With the current state of affairs, most of the classes can't be ported keeping all of its functionality and ease of use.
Title: Re: Documentation
Post by: John on October 05, 2018, 04:47:45 PM
That isn't what I was hoping to hear.

I can't say thank you enough for the outstanding job you are doing with the O2 docs.
Title: Re: Documentation
Post by: Charles Pegge on October 06, 2018, 12:25:27 AM
Hi Roland,

You can use pow(a,b) as an alternative to a^b, though they should give the same result.
Title: Re: Documentation - OT
Post by: John on October 06, 2018, 02:14:20 AM
Josť,

I plan to adapt your documentation format for my migration of Script BASIC as forum based to a GitLab repository. I already have GitLab CS installed on the hosting server but I need to deal with Plesk issues to get it working. I'm thinking it could be used as a sandbox of sorts.

Title: Re: Documentation extended data types
Post by: Arnold on October 06, 2018, 02:48:50 AM
Hi Charles,

this seems to be an overflow issue. Oxygen accepts a negative exponent up to 2^-16330. I will try to use logarithms (it has been so long since I used them)

Roland

Code: [Select]
uses console

extended e
e=-1.18973149535723176502e4932           'LDBL_MAX
printl e
e=2^16384
printl e
e=3.36210314311209350626e-4932           'LDBL_MIN  - min positive value
printl e
e=2^-16382    'Windows calculator
printl e
e=2^-16330
printl e

waitkey
Title: Re: Documentation
Post by: Arnold on October 08, 2018, 01:21:22 AM
Hi Josť,

you are incredibly fast and very systematic. The documentation will be a valuable addition to the Oxygen help file.

Will it eventually be possible to use the documentation for offline reading? At the moment, hyperlinks do not work if I copy the files as HTML pages (not a real problem).

Roland
Title: Re: Documentation
Post by: Josť Roca on October 08, 2018, 05:47:44 AM
Another way is to convert it to .pdf.

Given the address of a page

https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Data%20Types.md

change the github part of the address to gitprint in your browser:

https://gitprint.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Data%20Types.md

Although it does not support hyperlinks.
Title: Re: Documentation
Post by: John on October 08, 2018, 06:12:29 PM
I was pleased to see O2 code written by Josť Roca. It may not be his includes but classic Josť none the less. (sub class example)

Code: OxygenBasic
  1. $ filename "test4.exe"
  2. uses rtl64
  3. uses MinWin
  4. uses User
  5. uses Comctl
  6. #lookahead
  7.  
  8. %GWLP_WNDPROC = -4
  9.  
  10. function WinMain() as sys
  11.  
  12.    WndClass wc
  13.    MSG      wm
  14.    sys inst = GetModuleHandle 0
  15.  
  16.    sys hwnd, wwd, wht, wtx, wty, tax
  17.  
  18.    wc.style = CS_HREDRAW or CS_VREDRAW
  19.    wc.lpfnWndProc = &WndProc
  20.    wc.cbClsExtra = 0
  21.    wc.cbWndExtra = 0    
  22.    wc.hInstance = GetModuleHandle 0
  23.    wc.hIcon=LoadIcon 0, IDI_APPLICATION
  24.    wc.hCursor=LoadCursor 0,IDC_ARROW
  25.    wc.hbrBackground = GetStockObject WHITE_BRUSH
  26.    wc.lpszMenuName =0
  27.    wc.lpszClassName =@"Demo"
  28.  
  29.    RegisterClass (&wc)
  30.  
  31.    Wwd = 320 : Wht = 200
  32.    Tax = GetSystemMetrics SM_CXSCREEN
  33.    Wtx = (Tax - Wwd) /2
  34.    Tax = GetSystemMetrics SM_CYSCREEN
  35.    Wty = (Tax - Wht) /2
  36.  
  37.    hwnd = CreateWindowEx(0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0)
  38.  
  39.    sys hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, _
  40.                               "Edit", _
  41.                               "", _
  42.                               WS_CHILD OR WS_VISIBLE OR WS_TABSTOP, _
  43.                               20, 30, _
  44.                               250, 25, _
  45.                               hWnd, 102, _
  46.                               inst, 0)
  47.    SetWindowSubclass hEdit, &EditSubclassProc, 102, 0
  48.    SetFocus hEdit
  49.  
  50.    ShowWindow hwnd,SW_SHOW
  51.    UpdateWindow hwnd
  52.  
  53.    WHILE GetMessage(&wm, 0, 0, 0) > 0
  54.       IF IsDialogMessage(hWnd, &wm) = 0 THEN
  55.          TranslateMessage(&wm)
  56.          DispatchMessage(&wm)
  57.       END IF
  58.    WEND
  59.  
  60. End Function
  61.  
  62. function WndProc (sys hWnd, uint wMsg, sys wParam, sys lparam) as sys callback
  63. '==================================================================
  64.  
  65.     SELECT wMsg
  66.        
  67.       CASE WM_CREATE
  68.          EXIT FUNCTION
  69.  
  70.  
  71.       CASE WM_COMMAND
  72.          SELECT CASE LOWORD(wParam)
  73.             CASE IDCANCEL
  74.                ' // If the Escape key has been pressed...
  75.               IF HIWORD(wParam) = BN_CLICKED THEN
  76.                   ' // ... close the application by sending a WM_CLOSE message
  77.                  SendMessage hwnd, WM_CLOSE, 0, 0
  78.                   EXIT FUNCTION
  79.                END IF
  80.          END SELECT
  81.  
  82.       CASE WM_DESTROY
  83.          PostQuitMessage 0
  84.  
  85.     END SELECT
  86.  
  87.    function = DefWindowProc hWnd,wMsg,wParam,lParam
  88.  
  89. end function ' WndProc
  90.  
  91. FUNCTION EditSubclassProc (sys hWnd, uint wMsg, sys wParam, sys lparam, uIdSubclass, dwRefData) as sys callback
  92.  
  93.    SELECT CASE wMsg
  94.       CASE WM_DESTROY
  95.          ' // REQUIRED: Remove control subclassing
  96.         RemoveWindowSubclass hwnd, &EditSubclassProc, uIdSubclass
  97.  
  98.       CASE WM_KEYDOWN
  99.          SetWindowText GetParent(hwnd), "ASCII " & STR(wParam)
  100.  
  101.    END SELECT
  102.  
  103.    FUNCTION = DefSubclassProc(hwnd, wMsg, wParam, lParam)
  104.  
  105. END FUNCTION
  106.  
  107.  
  108. WinMain
  109.  
Title: Re: Documentation
Post by: John on October 13, 2018, 12:18:54 PM
Josť,

What editor do you use for writing code?

Title: Re: Documentation
Post by: Josť Roca on October 13, 2018, 02:49:51 PM
Oxide. Not useful for anything but to run smalls tests.
Title: Re: Documentation
Post by: Josť Roca on October 13, 2018, 07:02:14 PM
Maybe a free editor such Notepad++ could be used. It needs to be able to save the file in UTF-16 and UTF-8 besides ansi now that a future version of O2 will understand them.
Title: Re: Documentation
Post by: John on October 13, 2018, 07:18:57 PM
I have been using UltraEdit since it first was released when it was only Ian (owner/author) and a message from god to write it.
Title: Re: Documentation
Post by: Josť Roca on October 13, 2018, 07:26:16 PM
I said free. If somebody wants to use a commercial editor it is up to him.
Title: Re: Documentation
Post by: John on October 14, 2018, 07:15:24 AM
Microsoft Code (https://code.visualstudio.com/) editor (free/open source) is great editor with tons of features and an active project. I use it occasionally on Linux.
Title: Re: Documentation
Post by: John on October 14, 2018, 08:10:28 AM
I'm curious why Windows MAXINT for 64 bit has a greater range than 64 bit on Linux?


WINDOWS -  18446744073709551615
LINUX -            9223372036854775807

Title: Re: Documentation
Post by: Josť Roca on October 14, 2018, 10:57:45 AM
The first one is the value of unsigned 64 bit integers and the 2nd one for signed 64 bit integers. O2 only supports natively signed 64 bit integers (quad). I don't know about Linux.
Title: Re: Documentation
Post by: John on October 14, 2018, 11:30:25 AM
Thanks for the clarification!

The Windows MAXINT was from your UINT64 O2 docs which now seems wrong if O2 only supports signed quads.

Are you showing ALL types, supported by O2 or not?

Title: Re: Documentation
Post by: Josť Roca on October 14, 2018, 04:09:37 PM
I'm showing the Windows Data Types and the O2's typedefs that can be used to emulate them. They are not native data types implemented in the C++ compilers, but aliases. The purpose of my O2 typedefs is to allow to use C declares without having to change HWND to sys, etc.

If O2 does not support unsigned quads, then you won't have unsigned quads. You will be limited to signed quads.

It is not a full list of C++ typedefs. There are thousands of them. For example, to work with COM we will have to add

typedef wchar OLECHAR;
typedef OLECHAR *LPOLESTR;
typedef OLECHAR *LPCOLESTR;

among many others.
Title: Re: Documentation
Post by: John on October 14, 2018, 04:33:21 PM
Okay, got it.

Thanks for the detailed explanation.
Title: Re: Documentation
Post by: John on November 03, 2018, 11:25:28 AM
It is.now approaching a month since the docs have been touched. Is there a shelf life with your participation?
Title: Re: Documentation
Post by: Charles Pegge on November 04, 2018, 01:40:54 AM
I think Josť is waiting for me to catch up :)
Title: Re: Documentation
Post by: John on November 04, 2018, 01:49:06 AM
Quote
I think Josť is waiting for me to catch up

Maybe if you you expand on what is working with what you have upload to Github in the last couple days it might motivate Josť to experiment. Who knows?
Title: Re: Documentation
Post by: Josť Roca on November 04, 2018, 03:44:17 AM
I don't know how I have to explain it to John: IT IS NOT A DOCUMENTATION PROJECT. They are draft pages in which I have been collecting information for personal use using markdown instead of a notebook. I don't know what I'm missing and I also don't know if all of what I have collected is correct. The redaction should also be modified because I have cut and pasted information from several sources: Microsoft, FreeBasic and PowerBasic. This can be acceptable for a draft, but not for formal documentation. I can't write anything of value about assembler and macros, and classes are going to change. Is that clear?

If anybody wants to use the draft pages for anything, he is welcome. I'm not in charge of the documentation. If I will do something with O2, I will do it at my own pace. I don't like to be pushed. It irritates me.

BTW, what have done you with O2 during that month, John?


Title: Re: Documentation
Post by: John on November 04, 2018, 08:42:48 AM
Always good to know where you stand on things. I hope you find the magic in O2 someday like I did.
Title: Re: Documentation
Post by: Arnold on November 04, 2018, 08:43:54 AM
Hi Josť,

your documents are already very helpful at this time and we should be very grateful that you took the time to do this. They help figure out the similarities and differences to other programming languages, and I think they also help Charles to develop new ideas. Your and Mike's contributions are always worth thinking about.

Roland
Title: Re: Documentation
Post by: John on November 04, 2018, 09:40:09 AM
Well said Roland. Josť is an amazing talent and a good person others should try to emulate. Charles will always be the wizard that comes through when others say it's impossible.
Title: Re: Documentation
Post by: John on November 05, 2018, 02:14:42 AM
Josť,

It seems your O2 repository is editable and allows deleting of pages. Are you sure that is what you want to do?
Title: Re: Documentation
Post by: Josť Roca on November 05, 2018, 05:40:10 AM
I'm not going to take the burden of maintaining the documentation. How I'm going to do a good job documenting a language that I still don't know? As I said, these are draft pages for personal use.

Today, I have modified a page to add this information found in a post of Charles in the "Custom Controls in OxygenBasic" thread:

Quote
there are 2 forms of at

mytype v at p 'direct coupling to pointer p
if p changes then so does @v

mytype v at (p) 'the address is the value of the expression (p)
@v is independent of p thereafter

How many things I'm still missing?

You want to drag me to a project about which I still have doubts.
Title: Re: Documentation
Post by: John on November 05, 2018, 10:02:06 AM
No problem. I can change the URL to All BASIC for GitLab CE.

Charles,

The GitLab CE account you setup is active and ready for your use. The only difference is the URL.

https://sandbox.allbasic.info

Feel free to play in your sandbox as you see fit. (public / private repos)

Bonus, it's loaded with toys.  ;)
Title: Re: Documentation
Post by: Charles Pegge on November 06, 2018, 02:31:18 AM
Thanks, John. I'll take a look but for now, I have zero time-slots.
Title: Re: Documentation
Post by: Charles Pegge on November 06, 2018, 02:56:08 AM
Josť,

I will endeavour to draw your attention to any technical aspects which differ from PB/FB.

While we are discussing pointers, the '*'  operator is occasionally used directly for dereferencing. It's default type is 'sys' but it may be cast.

Code: [Select]
int a
int b = @a
a=0x1234
print hex *b
print hex cast byte *b '34

PS:
I'm currently working on unsigned quads. It's  more tricky than anticipated (for 32bit binaries). I think they should be called qwords.
Title: Re: Documentation
Post by: Josť Roca on November 06, 2018, 07:55:11 AM
Anybody that has used pointers with another basic dialect will try to write that code as:

Code: [Select]
dim a as long
dim b as long ptr = @a
a = &h1234
print hex(*b)

But unless you use the #cpointer on directive, it won't work. And what is worse, you won't know why because the compiler doesn't give any error.

I'm very picky with error checking, but assembler guys apparently not.
Title: Re: Documentation
Post by: Arnold on November 06, 2018, 09:49:19 AM
If I recall this correctly then with my 32-bit Vista computer the OS would have crashed officially with a message if I had used: dim b as long ptr = @a or: long *b = @a. Now with my 64-bit system the app only terminates silently. This is indeed a bit problematic. I can only see this happen when co2.exe disappears from my task manager.

The directive #cpointer seems to offer some hidden extra features?
Title: Re: Documentation
Post by: Josť Roca on November 06, 2018, 10:23:06 AM
This works without #cpointer:

Code: [Select]
dim a as long
dim b as long = @a
a = &h1234
print hex(*b)

but this does not:

Code: [Select]
dim a as long
dim b as long ptr = @a
a = &h1234
print hex(*b)

Assigning a pointer to a variable that has been declared as long

dim b as long = @a

and then deferencig it with *

print hex(*b)

goes against all that we have learned.

> The directive #cpointer seems to offer some hidden extra features?

It allows to use pointers as we are used to.
Title: Re: Documentation
Post by: Charles Pegge on November 06, 2018, 01:47:00 PM
In Basic, parameters passed to a function by reference, are really pointered variables. But you never need pointer syntax to use them. You just handle them like any other variable.

This is the rationale for not using pointers explicitly. It produces cleaner code.

the #cpointer switch is only there to support C header #define macros. It won't work directly on pointer members.


A few ways to dim  pointered variables:
Code: [Select]
dim byref a, byref b as single
dim as single byref a, byref b
single ptr a, ptr b
single *a,*b

PS:
This works:
Code: [Select]
dim a as long
dim b as long ptr : @b = @a 'coupling by address
a = &h1234
print hex(b)
Title: Re: Documentation
Post by: Josť Roca on November 06, 2018, 06:33:13 PM
Quote
the #cpointer switch is only there to support C header #define macros. It won't work directly on pointer members.

Then why this code works?

Code: [Select]
#cpointer on
dim a as long
dim b as long ptr = @a
a = &h1234
print hex(*b)
Title: Re: Documentation
Post by: Charles Pegge on November 06, 2018, 08:41:48 PM
I mean pointer members expressed with ->

a->b

I'm reviewing the situation, but o2 currently relies entirely on the type definition to resolve indirect (pointer) members.

'@' is the same as '&' and is still recognised in #cpointer mode, so your example still works.

#cpointer can be turned on and off as required, but I hope that its use will be rare.
Title: Re: Documentation
Post by: John on November 08, 2018, 03:57:51 PM
Hi Charles,

I have the Script BASIC Development (https://sandbox.allbasic.info/scriptbasic/development) repository available in the All BASIC Sandbox. This might give you an idea how the Oxygen Basic Development project might look if you decide to use the resource. I plan to clone the development repo to GitLab in a release format.

GitLab is very kind to open source projects. (FREE)

John

Title: Re: Documentation
Post by: Charles Pegge on November 09, 2018, 08:57:45 AM
Thanks John.

We used to think of programs as 'listings' but today, your typical program is more like a database.
Title: Re: Documentation
Post by: John on November 09, 2018, 09:15:58 AM
The top two reasons to use a Git repository is for source control and documentation.
Title: Re: Documentation
Post by: John on November 10, 2018, 06:34:33 PM
Charles,

Is your plan to release self compile and Josť's requests at one time? What is your ETA?
Title: Re: Documentation
Post by: Charles Pegge on November 11, 2018, 01:06:08 PM
Yes, it's easier to keep it all together, and we might need to discuss implementation details before release. They are not cast in stone. (Each of the OXSC zips contain a working oxygen.dll)
Title: Re: Documentation
Post by: John on November 11, 2018, 01:52:06 PM
Would it be of any help setting up the O2 sandbox repository using the latest OXSC zip?
Title: Re: Documentation
Post by: Charles Pegge on November 12, 2018, 07:22:38 PM
One day I hope to be able to hand over for open-source management.

But the most useful tool at the moment is FindEd which sits in the tools folder, and is accessible from Oxide (ctrl-F7). It is very efficient at tracking keywords over files in multiple folders, and doing simple editing. I find it is possible to code far more accurately with this tool than with a conventional IDE, or notepad :).

I'm include a compiled copy of FindEd in each OXSC file.
Title: Re: Documentation
Post by: John on November 12, 2018, 07:30:43 PM
The sandbox isn't an IDE but a blockchain like source control system. The past is always a previous commit away.
Title: Re: Documentation
Post by: John on November 25, 2018, 09:14:02 PM
Enabling Visual Styles (https://docs.microsoft.com/en-us/windows/desktop/controls/cookbook-overview)

I thought this might be of interest to you Roland.
Title: Re: Documentation
Post by: Arnold on November 26, 2018, 12:50:41 AM
Hi John,

thank you for the link. Visual styles are probably of general interest. In Oxygenbasic .res files with a manifest can be created with tools\GoRC.exe and linked to an .exe or .dll file with \tools\LinkRes2exe.exe. A simple example can be found in \examples\WinDynDialogs\ExeWithRes.

Roland
Title: Re: Documentation
Post by: John on December 01, 2018, 07:41:32 PM
I setup an Oxygen Basic (https://sandbox.allbasic.info/oxygenbasic/o2-dev) project in the All BASIC sandbox.

I have already added you Charles as a maintainer. If anyone else would like to contribute to the O2 documentation project, send me a PM and I'll setup an account for you. (serious inquires only)

If you find something you would like to add to the docs but don't want to commit to much more, download the .md markdown file, edit it and post it as an attachment. PLEASE follow Josť Roca's formatting standards.

The plan is to get markdown syntax highlighting for both O2 and Script BASIC working in the sandbox.

@Charles - This will gve you a way to enhance / correct the docs that Josť contributed. It will probably be best to not upload source until you release the self compile version.
Title: Re: Documentation
Post by: John on December 02, 2018, 03:34:35 PM
I have replaced the link to the O2 documentation project to the O2-DEV sandbox.

Here is the Archive Link - Josť Roca WinPBX O2 Documentation (https://github.com/JoseRoca/WinPBX/tree/master/docs/Oxygen)

I have Sticky enabled this thread for future reference.
Title: Re: Documentation
Post by: John on December 02, 2018, 05:54:08 PM
Hi Brian,

You are welcome to setup a project in the O2 sandbox to document your BASIC to O2 translator syntax and resulting O2 code. Something like what your doing on the JRS forum.

Title: Re: Documentation
Post by: Brian Alvarez on December 02, 2018, 08:16:32 PM
Thanks John. Right now im very busy to do it, but maybe later this month. At least i have been successfully compiling applications using portions of Jose Roca's includes. Thats gonna be a very nice thing to write about.
Title: Re: Documentation
Post by: John on December 02, 2018, 08:56:21 PM
Sounds exciting!

Let me know when you are ready.
Title: Re: Documentation
Post by: John on December 02, 2018, 09:01:22 PM
Quote
At least i have been successfully compiling applications using portions of Jose Roca's includes.

That may be a problem. Jose hasn't authorized his includes for anything but PowerBasic and FreeBasic. He was very specific about that point when I tried to promote O2 use.

Title: Re: Documentation
Post by: Mike Lobanovsky on December 03, 2018, 03:05:37 AM
That may be a problem. Jose hasn't authorized his includes for anything but PowerBasic and FreeBasic. He was very specific about that point when I tried to promote O2 use.

Yes, I second John's concerns in this regard.

Jose, will you please update us on what the O2 developers (and I do regard Brian's work as an important part of OxygenBasic's own development process) can and cannot do with your PowerBASIC headers as a new reincarnation of PB is evolving thanks to Brian's efforts to utilize (and more often than not bend) O2 to serve as a major compiler back end on the 64-bit Windows platforms?
Title: Re: Documentation
Post by: Brian Alvarez on December 03, 2018, 02:28:55 PM
Hmm, i didnt know that. Lets see what Jose says about this. We are going to have to go with whatever he says.

 For compiling DDT-style applications, PluriBASIC does not need other headers than the equates for the styles and windows notifications, thats all. For SDK, the declarations are required.
Title: Re: Documentation
Post by: John on December 03, 2018, 07:38:27 PM
You can't control what is free and without bounds.

Your contributions and feedback is the only hope to set direction.
Title: Re: Documentation
Post by: John on December 04, 2018, 02:44:23 AM
Is the self compile Work-In-Process able to compile existing O2 examples in the distribution?
Title: Re: Documentation
Post by: Charles Pegge on December 04, 2018, 05:48:26 AM
Yes, John. Most of them. The exception is dynamic (secondary compiling), which has been dropped in favor of main compiling. A major part of my current work is testing all the examples.
Title: Re: Documentation
Post by: Mike Lobanovsky on December 04, 2018, 06:06:14 AM
The exception is dynamic (secondary compiling), which has been dropped in favor of main compiling.

(http://www.sherv.net/cm/emo/sad/teary-sad-face-smiley-emoticon.png)
Title: Re: Documentation
Post by: Charles Pegge on December 04, 2018, 06:53:32 AM
You can still jit-compile in any program, but using o2_basic o2_exec etc. It's more of a consolidation.
Title: Re: Documentation
Post by: John on December 04, 2018, 11:52:58 AM
Quote
I don't understand why you want to use my headers for PowerBasic if they aren't useful for 64-bit compiling. What I'm missing?

That is an obvious point I missed until now.

Title: Re: Documentation
Post by: Brian Alvarez on December 04, 2018, 03:23:09 PM
 We are programmers John. We make the computer do whatever we want. :)
Title: Re: Documentation
Post by: John on December 04, 2018, 04:12:36 PM
True but unfortunately we are only around for a time slice to enjoy it.
Title: Re: Documentation
Post by: John on December 04, 2018, 07:51:51 PM
I have setup the initial sandbox commit for where Charles was on 12/4/2018. (last WIP zip) I will maintain the sandbox repo until Charles does a release of self compile. The benefits are interested people can see all the hard work Charles has put into his project and changes to it moving forward. Once Charles is on board and comfortable using git for source control, I will transfer the Oxygen Basic project to Charles's account so he is the owner and not just a maintainer.

Title: Re: Documentation
Post by: Charles Pegge on December 04, 2018, 11:13:04 PM
There's more OXSCs coming down the line ...
Title: Re: Documentation
Post by: John on December 05, 2018, 12:38:30 AM
I'm ready for them.

(https://pics.cdnvia.com/pics/juegos/111-beisbol-con-mikey.jpg)
Title: Re: Documentation
Post by: John on December 05, 2018, 01:44:37 AM
Will DLLC still work with self compile?
Title: Re: Documentation
Post by: Charles Pegge on December 05, 2018, 03:19:22 AM
Yes, its one of the larger test programs, including Oxyscheme, and the Opengl Framework.
Title: Re: Documentation
Post by: John on December 05, 2018, 03:25:58 AM
You had me worried when you mentioned JIT was crippled.

Title: Re: Documentation
Post by: Charles Pegge on December 05, 2018, 06:22:30 AM
It was secondary JIT. I think I was the only user, and that was only for demo code.
Title: Re: Documentation
Post by: John on December 05, 2018, 01:01:40 PM
I would like to create 2 new directory trees from the root repo. PROJECTS for Script BASIC and thinBasic extensions. EXAMPLES for everything else. It would be nice if the examples could be grouped in like functionality categories.
Title: Re: Documentation
Post by: John on December 05, 2018, 01:27:18 PM
@Mike,

Do you have time to lend a management hand to get the O2 source control sandbox repo in order?

Title: Re: Documentation
Post by: John on December 05, 2018, 02:56:20 PM
Charles,

The sandbox has been updated with the 20181205 self compile update. The source control features seem to be working.


Sandbox Error

There seems to be a problem with the Let's Encryp SSL certificate preventing the sandbox from access. I have escalated the issue with Plesk.

Title: Re: Documentation
Post by: John on December 05, 2018, 08:50:56 PM
I would think that now the compiler is mostly written in BASIC, there would be more interest in helping out at the compiler level. A new challenge for Jose moving beyond docs and includes to a compiler developer.
Title: Re: Documentation
Post by: Mike Lobanovsky on December 06, 2018, 06:03:35 AM
@Mike,

Do you have time to lend a management hand to get the O2 source control sandbox repo in order?

No John,

I'm flattered by the offer but I'm afraid I've got too little spare time for hobbies ATM.

Sorry.
Title: Re: Documentation
Post by: Charles Pegge on December 06, 2018, 06:31:40 AM

The source code is around 10% direct Assembler, but there's loads more of it in compositional strings.

I'm trying to make it more palatable for sharing, but I would not expect anyone to get involved in the source code at this stage, unless they enjoy long code-walks :)


Very clever, that source comparison.
Title: Re: Documentation
Post by: John on December 06, 2018, 09:31:32 AM
Source control is s must if you wish to remain sane and efficient.

The sandbox code will look better once syntax highlighting is working. An advantage of having a local GitLab install.

Title: Re: Documentation
Post by: John on December 06, 2018, 09:11:17 PM
I have a temporary workaround that only seems to work with Chrome. Firefox will not allow to ignore the invalid certificate problem. You have to proceed ignoring the security warning.

https://sandbox.allbasic.info:8181/oxygenbasic/o2-dev

The problem is GitLab creates it's own Let's Encrypt certs and there is a flaw in the renewal process which exceeds the max count on the Let's Encrypt site.
Title: Re: Documentation
Post by: John on December 06, 2018, 09:48:53 PM
Charles,

Here is another view of the comparison. (side-by-side)

Title: Re: Documentation
Post by: John on December 09, 2018, 11:24:32 AM
O2 down and angry (https://www.telegraph.co.uk/business/2018/12/08/o2-slap-ericsson-multi-million-pound-bill-network-failure/amp/)

The network failed over an expired license shutdown.

Back to the sandbox.
Title: Re: Documentation
Post by: John on December 09, 2018, 07:11:37 PM
AIR came up with a workaround for the Firefox access problem to the sandbox When Let's Encrypt starts allowing certificates again for sandbox.allbasic.info I will re-enable HTTPS support.

Quote from: AIR@AllBASIC
Go into "History", select "Show All History", find the link to the sandbox, right-click, and select "Forget About This site"

Then try connecting.

AIR.

Here is the URL to use once the above is done.

https://sandbox.allbasic.info:8181/oxygenbasic/o2-dev

@Charles - If you want to get an idea what the sandbox looks like using syntax highlighting with compares, check out the SB-DEV project as it already has support for C.

@Josť - If you would like to update your docs in the O2 sandbox, just post a brief description of the addition or change and attach the .md file and I will update the sandbox. The offer still stands for an account for the sandbox so you can update it directly.



Title: Re: Documentation
Post by: Charles Pegge on December 10, 2018, 09:18:23 AM
Unfortunately, Firefox does not enter this link into its history. So it can't forget about it!
Title: Re: Documentation
Post by: John on December 10, 2018, 10:55:39 AM
You  can use Chrome if you have it to accept the expired cert. I hope to see Let's Encrypt certs soon.

It's true you can't rely on history if you were never there to see it in the first place. :'(
Title: Re: Documentation
Post by: John on December 14, 2018, 09:36:09 PM
The O2 sandbox has been updated with OXSC181215.

Quote from: Charles
04:27 15/12/2018 Fix Empty macro problem (replacewdt)
22:58 14/12/2018 Appe() uses copy() instead of mid()
18:37 14/12/2018 Fix "=" bug subsas (f=a)
18:35 14/12/2018 Support accum setting with += -= assignments (cpa>2)
04:19 14/12/2018 Revoke class-operators, retain macro-operators(findop)
19:09 13/12/2018 Work on nested scopes for epilog code
00:05 13/12/2018 Merge mcword into replacewdt
14:40 12/12/2018 Remove wword uword parsing (destructors 20)
02:43 12/12/2018 Refactor macso etc. (mac to mrc)
12:00 11/12/2018 Implement bycopy
Title: Re: Documentation
Post by: John on December 17, 2018, 03:41:06 PM
The O2 sandbox has been updated with OXSC181217.

Quote from: Charles
06:12 17/12/2018 Fix macro insider ## substitution (himac)
14:29 16/12/2018 Fix wide string literal binary encoding (makerecordw)
18:40 15/12/2018 Typeof returning text in chr(34) quotes (pars.inc newline)
06:04 15/12/2018 Revoke 'operator' methods & cleanup (findop)
Title: Re: Documentation
Post by: Charles Pegge on December 17, 2018, 08:49:04 PM
My dirty laundry list :)

I've removed a significant amount of redundant code.
Title: Re: Documentation
Post by: John on December 21, 2018, 12:20:44 AM
The O2 Sandbox is working again with HTTPS.

Charles,

Rather than waiting to build a OXSC milestone, you can use the sandbox web interface to upload a new version of the file giving it a commit comment.

This way you have better version control and recovery if needed.

A great way to verify your changes in a focused manner. (DIFF)

John
Title: Re: Documentation
Post by: John on December 21, 2018, 11:24:46 PM
Charles,

When do you think you will start releasing examples tested with the cloning compiler?

(https://www.pcrepairleeds.com/wp-content/uploads/2016/03/clones-chick.jpg)



Title: Re: Documentation
Post by: Charles Pegge on December 23, 2018, 03:42:29 PM
Hi John,

I'm still trying to nail down the set of features required for UDT operators. It has to be efficient down to the bare metal, as well as supporting higher-level types which might involve variants.
Title: Re: Documentation
Post by: John on December 23, 2018, 06:15:10 PM
VARIANTS.  ;D :-* 8)

I would be happy to do some testing of examples if you can give me a list of OXSC features still in the oven.
Title: Re: Documentation
Post by: John on December 23, 2018, 08:27:46 PM
Mr. Roca,

Do you still have any interest in continuing on with your O2 documentation project? Can I assume your silence is based on waiting for Charles's OXSC release? I hope I haven't offended you in any way. Not everyone likes what I have to say but that isn't a goal I'm chasing.
Title: Re: Documentation
Post by: John on December 31, 2018, 03:29:44 PM
The OXSC181230 update is in the sandbox.

I think a good way to learn O2 syntax is reviewing the compiler code itself. Charles has included over 4,500 lines of test code to try as well.
Title: Re: Documentation
Post by: Brian Alvarez on January 02, 2019, 08:01:22 AM
If variants are natively supported, i will surely use them instead of my own version. Not that my implementation is bad but the less conversions i have to make, the faster the compilation is.
Title: Re: Documentation
Post by: Aurel on January 02, 2019, 12:35:20 PM
Ok
Is there 32 bit version of selfcompiled Oxygen Basic or not?
I mean compiled exe in zip..so that we can try?
thanks

aha ..oK it is in sandBox...
but there is :
rtl32.inc
oxygen.dll



what about gxo2.exe ... or i can use old version ?
Title: Re: Documentation
Post by: Charles Pegge on January 03, 2019, 02:25:43 AM
Hi Aurel,

Older versions of gxo2.exe  compile using o2_asmo, which is now obsolete and o2_basic is used instead.

The new oxygen.dll is still a 32-bit replacement for the original.
Title: Re: Documentation
Post by: Charles Pegge on January 03, 2019, 02:49:57 AM
Hi Brian,

The latest o2 changes enable Classes/UDTs to be used directly in expressions with operators.

The operator-sets are defined in macros which are called by the compiler when it needs to encode an operation for the type of operand being used in an expression.

To show how it works I can produce a skeleton operator set for variants...

Title: Re: Documentation
Post by: Aurel on January 03, 2019, 05:08:17 AM
Quote
The new oxygen.dll is still a 32-bit replacement for the original.

HI Charles..

Ok i understand that
Is that mean that i don't need gxo2.exe ?
In that sandBox ..there is no o2_basic.exe ? ...right?
what looks strange to me  ???

or i must wait for new version which will work with new oxygen.dll ?
I am confused now.... and i don't know what compiler i can call from my editor.

You know that in my programs i use this:
awinh.inc
rtl32.inc
gxo2.exe
AurelEdit.exe or OxIde.exe
Title: Re: Documentation
Post by: jcfuller on January 03, 2019, 08:24:24 AM
Aurel,
  Try this one.

James
Title: Re: Documentation
Post by: Aurel on January 03, 2019, 10:09:16 AM
 Thanks James
I will try  :)
Title: Re: Documentation
Post by: John on January 04, 2019, 01:33:01 AM
Where does xo2.inc come from? (used as an include within gx02.bas source file)
Title: Re: Documentation
Post by: John on January 04, 2019, 03:32:41 PM
Is the only way to build a self compiling compiler is to to use the FreeBasic compiled version first yo build it?

@Chales - Can you post some instructions on building the OXSC suite?
Title: Re: Documentation
Post by: Charles Pegge on January 04, 2019, 06:12:50 PM
Hi John,

xo2.inc is a component of gxo2.bas (and previous exo2.bas)

Self-compiling is not recommended for public use yet but co2.exe is the compiler used in conjunction with a previously self-compiled oxygen.dll, and the source file is BuildOxygenDLL.o2bas.
Title: Re: Documentation
Post by: John on January 04, 2019, 07:30:54 PM
So the runtime (oxygen.dll) is using the self compiling (O2 BASIC) but the SC compiler itself is still a work in process?

I'm going to add to the runtime folder in the sandbox the gxo2.exe that James Fuller posted recently. That should make the sandbox repo more complete.

Can I assume gxo2.exe is static until the SC compiler is released?
Title: Re: Documentation
Post by: Charles Pegge on January 06, 2019, 03:53:24 AM
Hi John,

I'll post another OxygenBasicProgress.zip containing gxo2 and the current example files, so we are in sync.

I can also make OXSC more self-contained by including a 'revert' version of oxygen.dll to restore a failed build.

Oxygen.dll is compiled within the OXSC folder, then copied by batchfile into the main folder, as a separate step.
Title: Re: Documentation
Post by: John on January 06, 2019, 08:01:54 AM
I will more than likely make a new branch for the previous O2 version.
Title: Re: Documentation
Post by: John on January 15, 2019, 01:00:43 AM
Sandbox updated with OXSC190115.

It looks like you added variant support in this release Charles.
Title: Re: Documentation
Post by: John on January 15, 2019, 12:05:30 PM
Charles,

When you release the self compile compiler, will there be a 32 and 64 bit version of it?
Title: Re: Documentation
Post by: John on January 16, 2019, 07:37:43 PM
Charles,

I created a new project in the sandbox for O2-Classic. The sandbox icon link has been updated to give the visitor the choice of Classic or OXSC.
Title: Re: Documentation
Post by: Alex_Longard on January 17, 2019, 08:23:57 AM
Hello John,
Where Oxylog.txt?
I can't to find this file in Inf folder.

I see in:
https://github.com/Charles-Pegge/OxygenBasic
and
https://sandbox.allbasic.info:8181/oxygenbasic
Title: Re: Documentation
Post by: John on January 17, 2019, 09:54:58 AM
ALL files included in Charles 's ZIPs are in the Sandbox.
Title: Re: Documentation
Post by: John on January 17, 2019, 04:55:52 PM
If you have a program you would like to contribute to the O2 project, attached it to a post and I'll get it pushed to the sandbox.

If you find an example that doesn't run or you would like to improve it, those submissions are welcome as well.
Title: Re: Documentation
Post by: Charles Pegge on January 18, 2019, 01:51:54 AM
Charles,

When you release the self compile compiler, will there be a 32 and 64 bit version of it?

Hi John,

I don't have a stable 64bit self-compiling lineage yet. It is only a matter of time, and we can still go ahead with the 32bit.
Title: Re: Documentation
Post by: Alex_Longard on January 18, 2019, 02:56:02 AM
Hi John,
I try to rewrite VST sdk for O2, I just did not see examples for "prototypeof" and some others commands...
It is difficult to understand pointers in O2, after being used to writing on pure C and a bit strange PureBasic.
When I make a minimally working project, I want to put it in you sandbox so that other people can see how can write very fast and convenient code for DSP on O2.
Title: Re: Documentation
Post by: John on January 18, 2019, 10:09:26 AM
This is outside my level of expertise and Charles should test this and place it in the sandbox where he thinks it should go.

@Charles- You can use the web UI for the sandbox to add / change files. Just add a commit note so we know why it's there.
Title: Re: Documentation
Post by: Charles Pegge on January 22, 2019, 12:26:27 AM
Hi Alex,

I would be very interested to see your VST work. Perhaps we can include some in the package.

O2 hides its pointers. This is consistent with BASIC parameters passed byref, but opposite to the way pointers are handled in C. The variable address is set by left sided expressions like:

&v=pt
or
@v=pt
Title: Re: Documentation
Post by: Alex_Longard on January 26, 2019, 12:56:20 AM
Hi Charles!
I while write my first plugin in pure C,
and now i very slow write this in O2. I donít know how to write some functions that are not in O2, I have to use what is already there Msvcrt.inc.
This will work very badly, the plugin should be less dependent on winapi, unless it is a graphics functions.
Big thanks for your pointer example, it's very helpful to me!

There my code in last post:
https://www.kvraudio.com/forum/viewtopic.php?f=33&t=518049
Title: Re: Documentation
Post by: Arnold on July 17, 2019, 03:29:11 AM
Hi Charles,

somehow I overlooked the Docs folder of OxygenBasic on GitHub. This is really helpful information. Together with the help file of Oxygenbasic not many wishes remain open any more.

I noticed that in the section Control_Flow / Looping Statements you used the notation "exit ehile". Will "exit while" be deprecated at some time in favour of "break when"?

There is also the interesting section of Windows Data Types. Can the O2 definitions be used for these data types? Must the names of the Data Types be used in upper case, and will there be no conflicts e.g. HANDLE - handle, HBRUSH - hbrush, HWND - hwnd? As I apply case-insensitive code, these constructs look like magic to me. But if that works, I will use these definitions right away.

Roland
Title: Re: Documentation
Post by: Charles Pegge on July 17, 2019, 04:25:44 AM
Hi Roland,

These docs are the preliminary work of Josť Roca. They are a very good start but we will need to revise and extend them.

typedef long LONG will not cause recursion, even in case-insensitive mode. There is protection against this possibility.

On the other hand, dim as HANDLE handle can only be used in the case-sensitive modes


exit while will remain the standard, the others are more experimental.