Author Topic: A little brother of OxIde  (Read 26388 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Guest
A little brother of OxIde
« on: March 14, 2017, 05:57:57 AM »
Hello,

this is a project I started three weeks ago. It is a single file editor using the SciLexer.dll of OxygenBasic. As the development is in an early stage I only recommend to use it for experimental purpose.

On my first attempt I tried to use the OxIde functions but I found that OxideUtil.inc is too much specific to Oxide and also is developed to be used with OpenGl. So I applied only some functions modified a little bit. Nevertheless the editor is based on OxIde, so I see it as a little brother. As I was inspired by OxIde maybe this project will produce some ideas for OxIde too some day.  Attached is a running executable which should run with Windows Vista and later and the source code for running OxSciPed.o2bas with a Resource dll.

Running the first time OxSicPed.exe will create a config file. Probably the path for Oxygenbasic will not match and must be edited in OxSciPed.cfg. This config file must also be copied into the src folder.

At the moment there are some missing functions e.g. find / findreplace will do nothing, statusbar will need some work, context sensitive help is not yet done. But when these steps are finished it should be possible to develop and extend OxSciPed by itself.

Roland

Edit: Deleted and attached new version with later message

.
« Last Edit: April 03, 2017, 05:52:13 AM by Arnold »

Aurel

  • Guest
Re: A little brother of OxIde
« Reply #1 on: March 14, 2017, 08:27:22 AM »
Hi Arnold..
Nice  :)
..but one thing is not clear to me ..
where is scilexer.dll ?  :o
Do you compress editor exe?

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #2 on: March 14, 2017, 09:09:50 AM »
Hi Aurel,

SciLexer.dll is provided with OxygenBasic. If you installed OxygenBasic in d:\Oxygenbasic everything will work ok. Otherwise you have to change in OxSciPed.cfg d:\OxygenBasic to the correct path.

OxSciPed.exe was created from the code in the \src folder, but the resources were linked directly to the created executable. For modifying the source code of OxSciPed I will only need OxSciPed.dll at the moment.

Roland

Aurel

  • Guest
Re: A little brother of OxIde
« Reply #3 on: March 14, 2017, 11:15:40 AM »
Yes Arnold
I have Oxygen basic on disk D and many other folders where is scilexer  ;D
but this is little bit unusual way to load scilexer.dll ..right?
Ok everything work fine  :)

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #4 on: March 14, 2017, 11:55:06 PM »
Hi Charles,

I would like to add in the AboutBox of the editor something like this:
You are using OxygenBasic
Version:
(used version)

This would be interesting if I run OxSciPed.exe as an independant executable. Is there a simple way to get the version of the oxygen.dll which will be applied for co2.exe? Could I use Oxygen's compile function in some way?

Roland

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #5 on: March 15, 2017, 03:09:44 AM »
A small bug has slipped into the 'Open' option: a changed text will not be saved. I am about to solve this problem. At the moment one must save a file before opening a new one.

There is also a small mistake in OxSciShortcuts.txt. It must read:
  F5                Run .o2bas file
  F9                Run binary / exe file
                    (will eventually need Oxygen.dll)

There cannot be enough tests for such a kind of application.

Roland

Charles Pegge

  • Guest
Re: A little brother of OxIde
« Reply #6 on: March 15, 2017, 05:18:33 AM »
Thanks Roland,

I'm doing a  bit more work to clean up winutil.inc and transfer specialised messaging down to oxideutil.inc

I have not had a chance to study your OxSciPad yet but I will need to provide you with a new Oxygen.dll call o2_version() as string. The current API for Oxygen.dll can be found in inc/sysutil.inc

I have found that Oxide.exe (it must be in binary form),  will support direct compilation, without requiring gxo2.exe or co2.exe.

This allows greater flexibility for debugging and analytics with oxygen.dll under direct control.

the magic lines are
Code: [Select]
         o2_mode 9 'to use strings insteat of char*
         '
          'DIRECT COMPILING : ONLY WORKS WHEN OXIDE IS COMPILED (NO JIT!)
          o2_basic s
          if not o2_errno then
            o2_exec 0
          else
            print o2_error
          end if

Charles Pegge

  • Guest
Re: A little brother of OxIde
« Reply #7 on: March 15, 2017, 01:38:53 PM »
Unfortunately, it is not safe to use o2_exec in the same process as the IDE, so direct compiling is not feasible for JIT operations, but compiling to a binaries is ok.

Code: [Select]
          'DIRECT COMPILING : ONLY WORKS IN OXIDE.EXE
          if mo then
            o2_basic s 'COMPILE TO BINARY FILE DIRECTLY
            if o2_errno then
              s=o2_error
              print s
              cmsg="" ' "compiling error"
            end if
            SetWindowText hwnd,cmsg
          else 'JIT EXECUTION IN SEPARATE PROCESS
            s="\co2.exe" 'CO2 COMPILING
            's="\gxo2.exe" 'GXO2 COMPILING
            Exec qu+o2dir+s+qu+" "+qu+OxyPath(f)+qu 'RUN COMPILER AS A SEPARATE PROCESS
          end if

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #8 on: March 16, 2017, 12:26:32 AM »
Hi Charles,

I always learn something new with Oxygenbasic. I can use the code above and it would work quite nice but I will either need oxygen.dll in the folder of OxSciPed or add \Oxygenbasic path to the environment or make a copy of OxSciPed.exe in \Oxygenbasic folder. This is what I would like not to do.

On the other hand if I try to #define NoOxygenLib to declare the o2_* statements outside of SysUtil.inc e.g.

librarypath o2dir +"\"

  extern lib "oxygen.dll"
  ! o2_abst      (string s) as string
...

I will get this error when I start the exe file:
o2diroxygen.dll

Could I use loadlibrary / bind instead? But I think I must use unpototyped functions then.

Nevertheless the possibility to use oxygen.dll in an independant executable offers some interesting options. Does a summary exist somewhere about the intended use of the o2_* functions?

Roland

Charles Pegge

  • Guest
Re: A little brother of OxIde
« Reply #9 on: March 16, 2017, 02:47:46 AM »

Hi Roland,

LibraryPath is currently 'baked' at compile time, (or JIT time). You can only use a literal path name.

It is certainly possible to use late-binding techniques for any dll, using LoadLibrary / GetProcAddress etc.
You will find an example in ProjectsC\thinBasicOxygen which has the source code for the thinBasic modular interface.

But your simplest option is to compile the IDE as an oxygen-dependent binary and drop a copy into the OxygenBasic folder. Then create a shortcut for it, should you wish to run it from the desktop, for example.

For an independent system,  as an alternative to the standard OxygenBasic environment, you will need to include oxygen.dll, sciLexer.dll and co2.exe (or gxo2.exe)

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #10 on: March 16, 2017, 03:29:03 AM »
Thank you Charles. I found the ThinBasicOxygen folder and I will study the examples to learn more about the possible usage of Oxygen.dll as an external library.

Roland

Charles Pegge

  • Guest
Re: A little brother of OxIde
« Reply #11 on: March 16, 2017, 04:39:43 AM »
Here is a late binding for oxyen in oxygen, without the complexities of the thinBasic module.

Code: [Select]
#file "LateBinding.exe"
extern
   !* o2_abst      (string s) as string
   !* o2_asmo      (string s) as sys
   !* o2_assemble  (string s) as sys
   !* o2_basic     (string s) as sys
   !* o2_exec      (sys p=0)  as sys
   !* o2_buf       (sys n)    as sys
   !* o2_errno     ()         as sys
   !* o2_error     ()         as string
   !* o2_get       ()         as string
   !* o2_len       ()         as sys
   !* o2_link      ()         as sys
   !* o2_mode      (sys m)
   !* o2_pathcall  (sys m)
   !* o2_prep      (string s) as string
   !* o2_put       (string s)
   !* o2_varcall   (sys m)
  ' !* o2_version   () as string
   !* o2_view      (string s) as string
  end extern

  sys oxl=loadlibrary "oxygen.dll"
  if oxl then
    def link @%1=getprocaddress oxl, "%1"
    '@o2_abst=getprocaddress oxl,"o2_abst"
    link o2_abst
    link o2_asmo
    link o2_assemble
    link o2_basic
    link o2_exec
    link o2_buf
    link o2_errno
    link o2_error
    link o2_get
    link o2_len
    link o2_link
    link o2_mode
    link o2_pathcall
    link o2_prep
    link o2_put
    link o2_varcall
   ' link o2_version
    link o2_view
  end if

  if not oxl then
    print "Cannot locate oxygen.dll"
    end
  end if

  o2_mode 9 'for oxygenBasic ascii strings

  o2_basic "print `helo`"

  if o2_errno then
    print o2_error
  else
    o2_exec
  end if

And a more cautious version with checks for missing Proc Addresses:

Code: [Select]
#file "LateBinding.exe"
extern
   !* o2_abst      (string s) as string
   !* o2_asmo      (string s) as sys
   !* o2_assemble  (string s) as sys
   !* o2_basic     (string s) as sys
   !* o2_exec      (sys p=0)  as sys
   !* o2_buf       (sys n)    as sys
   !* o2_errno     ()         as sys
   !* o2_error     ()         as string
   !* o2_get       ()         as string
   !* o2_len       ()         as sys
   !* o2_link      ()         as sys
   !* o2_mode      (sys m)
   !* o2_pathcall  (sys m)
   !* o2_prep      (string s) as string
   !* o2_put       (string s)
   !* o2_varcall   (sys m)
   !* o2_version   () as string
   !* o2_view      (string s) as string
  end extern

  sys oxl=loadlibrary "oxygen.dll"
  if oxl then
    string errs
    def link
      @%1=getprocaddress oxl, "%1"
      if not @%1 then errs+="%1 is missing"+chr(13,10)
    end def
    '@o2_abst=getprocaddress oxl,"o2_abst"
    link o2_abst
    link o2_asmo
    link o2_assemble
    link o2_basic
    link o2_exec
    link o2_buf
    link o2_errno
    link o2_error
    link o2_get
    link o2_len
    link o2_link
    link o2_mode
    link o2_pathcall
    link o2_prep
    link o2_put
    link o2_varcall
    link o2_version
    link o2_view
  end if

  if not oxl then
    print "Cannot locate oxygen.dll"
    end
  end if

  if errs then
    print errs
    end
  end if

 o2_mode 9 'for oxygenBasic ascii strings

  o2_basic "print `helo`"

  if o2_errno then
    print o2_error
  else
    o2_exec
  end if
« Last Edit: March 16, 2017, 04:56:20 AM by Charles Pegge »

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #12 on: March 16, 2017, 08:27:53 AM »
Charles,

this is really fabulous. I used your first example and did these modifications:

'#file "LateBinding.exe"
$ filename "LateBinding1.exe"
#include "$/inc/RTL32.inc"
....

'  sys oxl=loadlibrary "c:\OxygenBasic\oxygen.dll"

  string o2dir="c:\oxygenbasic_241116" 
  sys oxl=loadlibrary o2dir + "\oxygen.dll"
...

  print "Program compiled with version: " version

  o2_mode 9 'for oxygenBasic ascii strings
 
  o2_basic "print `You are using oxygen.dll version:` version"

  if o2_errno then
    print o2_error
  else
    o2_exec
  end if

and I get the expected results. This is exactly what I was looking for. I did not yet try to find out, but I assume there is a way to store the value of the second result in a variable?

Roland


.

Charles Pegge

  • Guest
Re: A little brother of OxIde
« Reply #13 on: March 17, 2017, 07:01:03 AM »
Not directly, which is why o2_version will be required.

I will also remove some ancient fossils from the API, and annotate each API function in src\oxygen.bas

These will disappear

o2_assemble
o2_get
o2_put

Arnold

  • Guest
Re: A little brother of OxIde
« Reply #14 on: March 17, 2017, 12:56:45 PM »
This is the intermediate state of my little Oxygenbasic editor. I hopefully fixed the mistake of missing to save a modified textfile before opening a new file. I added an additional bitmap in the toolbar for closing a textfile. Also added some messages in the statusbar for Row/Col and INS(sert) / OVR(type).

Unfortuately the Find and Find/Replace dialog with Scintilla is a bit more complicated than I expected and will be a bit delayed.

Roland

Edit: Deleted and attached new version with later message
« Last Edit: April 03, 2017, 05:51:37 AM by Arnold »