Author Topic: Documentation  (Read 65762 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: Documentation
« Reply #45 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.

JRS

  • Guest
Re: Documentation
« Reply #46 on: September 30, 2018, 09:56:06 PM »
I have added a link to José Roca's O2 documentation project under the wizard.

  • Guest
Re: Documentation
« Reply #47 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.

JRS

  • Guest
Re: Documentation
« Reply #48 on: October 01, 2018, 10:42:11 AM »
Can you start a wishlist so Charles knows what are the important features that are missing?

  • Guest
Re: Documentation
« Reply #49 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.
« Last Edit: October 01, 2018, 12:29:29 PM by José Roca »

JRS

  • Guest
Re: Documentation
« Reply #50 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.

Aurel

  • Guest
Re: Documentation
« Reply #51 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?

José Roca

  • Guest
Re: Documentation
« Reply #52 on: October 01, 2018, 01:35:55 PM »
You can use ANY PTR.

JRS

  • Guest
Re: Documentation
« Reply #53 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?

  • Guest
Re: Documentation
« Reply #54 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.
« Last Edit: October 02, 2018, 04:32:18 AM by José Roca »

JRS

  • Guest
Re: Documentation
« Reply #55 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)

  • Guest
Re: Documentation
« Reply #56 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.
« Last Edit: October 02, 2018, 06:19:13 AM by José Roca »

JRS

  • Guest
Re: Documentation
« Reply #57 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.

José Roca

  • Guest
Re: Documentation
« Reply #58 on: October 02, 2018, 06:21:02 AM »
I hope that Charles will understand what I mean, because you have no clue. Sorry.

JRS

  • Guest
Re: Documentation
« Reply #59 on: October 02, 2018, 06:26:59 AM »
Even a blind pig can find food in the mud.