Oxygen Basic

Programming => Bugs & Feature Requests => Topic started by: Emil_halim on April 19, 2014, 03:18:26 AM

Title: error with the latest Oxygen DLL
Post by: Emil_halim on April 19, 2014, 03:18:26 AM
Hi Charles,

I have just download the latest Oxygen DLL , then i tested on of my old HLasm with OXYgenbasic.

i got a wrong result with new upgrade.

here is my example
Code: [Select]
//*********************************
//*  test program by Emil Halim   *
//*       5 / 4 / 2013            *
//*********************************

indexbase 0
includepath "$/inc/"
$ filename "AscToDword.exe"
#include "RTL32.inc"

zstring a[]="12345"

   addr edx,a : gosub AscToDwor_proc : add eax , 10
   print eax   //12355
end

==========================
AscToDwor_proc:

          xor eax, eax               ; clear eax
 ^  @@:   movzx byte ecx, [edx]      ; move 1 byte into ecx
 ^        lea eax, [eax+eax*4]       ; eax = 5 * eax
 ^        lea eax, [eax*2+ecx-30h]   ; eax = 2 * eax + (ecx-30h)
 ^        edx++                      ; inc edx
 ^        cmp byte[edx], 0           ; if end of string then return
 ^        jne @b
 ^        ret
 
Quote
it prints 212353  instead of 12355

any help please?
Title: Re: error with the latest Oxygen DLL
Post by: Emil_halim on April 19, 2014, 08:30:40 AM
Hi Peter,

welcome to Oxygen basic forum.

thanks you , i think the problem is old oxy dll was know the hex syntax 30h , but the new one did not.

Charles can you fix this please.
Title: Re: error with the latest Oxygen DLL
Post by: Emil_halim on April 19, 2014, 12:21:35 PM

Hi Charles,

I have found another problem with the new oxy dll.

i have a declared dll function like this
Code: [Select]
! Graphics3D       "_Graphics3D@20"(Dword Width,Height,depth=32, boolean fullScrn=false,VSync=false)

it was working okay, and now give me this error
Quote
ERROR:   parameters mismatch for procedure graphics3d:
params given : #long#long#long#long#long#long@000_00

OPTIONS:
graphics3d(dword,dword,dword,dword,dword)

WORD:    0
LINE:    28
FILE:    main source
PASS:    2
>Exit code: 0

i call it like this
Code: [Select]
Graphics3D(800,600)

so what could be the error here?
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 19, 2014, 02:45:17 PM
I think that something is wrong with new dll
because with old my programs work but with new i receive strange errors like
is on pic...

.
Title: Re: error with the latest Oxygen DLL
Post by: Emil_halim on April 19, 2014, 11:33:10 PM
Hi Peter,

thanks , BTW that means the old version was buggy so it accepted boolean type.

any way , my big wish is that Oxygen basic is a bug free, so that i can trust in it's results.
 
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 19, 2014, 11:53:52 PM
Hi Emil,

Yes, I was attempting to remove undesirable number suffixes: h and o and e should be allowed through.

quick dll update:
http://oxygenbasic.org/o2zips/Oxygen.zip

As in C, bool is really an 32 bit integer

Test code:
Code: [Select]

typedef bool boolean
def true -1
def false 0


function Graphics3D "_Graphics3D@20" _
(Dword Width,Height,depth=32, boolean fullScrn=false,VSync=false)
print "depth " depth
end function

Graphics3D 100,200


---------------

'numbers with suffixes:

print 101h      '257
print 101o      '65
print 101.0e-4  '0.0101

Aurel, can you please provide an example of the string problem
Title: Re: error with the latest Oxygen DLL
Post by: Mike Lobanovsky on April 20, 2014, 12:07:57 AM
What is the exact idea behind TRUE = -1, Charles?
Title: Re: error with the latest Oxygen DLL
Post by: Emil_halim on April 20, 2014, 12:13:08 AM
thanks Charles,

i have another problem , see this declaration
Code: [Select]
! LoadMesh           "_LoadMesh@12"(char* file="", sys EntityParent=0, char* meshName="") as sys
when calling it like that
Code: [Select]
ogrehead = LoadMesh("ogrehead.mesh",0)

i got this error
Quote
Linker found unidentified names:
file:   level 0
meshname:   level 0

BTW , the function accepts an empty NULL string as a default parameter , not a null pointer.

any help please.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 20, 2014, 02:29:31 AM
Emil,

(re-edited)
 I had not not considered using strings as default params.

there is an issue with '*' and default values

One solution is to use string instead of char*. They are compatible in this context.

Another is to create a char* type

Code: [Select]
typedef char *pchar

function f(pchar s="")
print strptr s
end function

f

Mike, -1 is a Basic truth :). Oxygen only does bitwise logic, currently.
Title: Re: error with the latest Oxygen DLL
Post by: Mike Lobanovsky on April 20, 2014, 03:06:40 AM
Bulgarians nod to say "No" and shake their heads to say "Yes". :D
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 20, 2014, 02:25:55 PM
Is this correct?

With nose pointing in the z axis

Bulgarian Yes:  glRotatef 20,0,0,1
Bulgarian No:   glRotatef  20,1,0,0
Title: Re: error with the latest Oxygen DLL
Post by: Mike Lobanovsky on April 20, 2014, 04:58:58 PM
Yes Charles, (that's a usual human "yes" :D )

You're perfectly correct. In fact, I was even trying to look up a better English word than "shake" in the dictionary but I failed - you don't have any other one to convey negation (neither do we BTW). By "shaking one's head" negatively, the English and the rest of the world (oh, those imperialistic lingual relics! ;) ) imply

glRotate(+/-20,0,1,0)

a few times and that's only natural and clear for all other earthlings but Bulgarians. They would convey negation by a one-time nod

glRotate(-/+20,1,0,0)

while their agreement would be conveyed with a one-time tilt

glRotate(-/+20,0,0,1)

of their head to their left shoulder, both gestures being performed invariably in that particular polarity.

It's almost impossible to communicate with a Bulgarian waiter in a restaurant; you have to ask them again and again until they would vocalize their answers.

But in ordinary life it's a convenient and customary simplification to say that Bulgarians just do it "the other way round" compared to us ordinary mortals. :)
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 20, 2014, 07:48:14 PM

Indian folks often do a few glRotatef +/-10,0,0,1 to indicate they agree with you. That could be a 'yes' but it certainly confused the Brits.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 20, 2014, 08:35:30 PM
Another update for Emil. This fixes the default param '*' problem

quick dll update:
http://oxygenbasic.org/o2zips/Oxygen.zip

Code: [Select]
function f(char*s="Hello")
print s
end function

f

f "Hello World!"
Title: Re: error with the latest Oxygen DLL
Post by: Emil_halim on April 21, 2014, 07:37:51 AM

thank's Charles.

works well here.

may i ask you about the states of c style syntax please.   
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 21, 2014, 08:34:15 AM
Apart from occasional header fixes, further C syntax (c pointers & arrow notation etc)  has a low priority at present.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 23, 2014, 10:30:10 PM
Quote
Aurel, can you please provide an example of the string problem

Charles
Because i keep old oxygen dll-s i have tested my programs with this older versions
and in all this thing work properly but not in this new.
look in screenshot ...
it seems that parser not recognize keyword As properly  ???

.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 24, 2014, 01:39:58 AM
Thanks Aurel,

Could you try this release, an see what happens. I have removed 'as' as a casting keyword. I don't think anyone is using it for casting.

http://www.oxygenbasic.org/o2zips/Oxygen.zip
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 03:44:28 AM
Ok Charles
But i am not sure what kind of casting is here  ???
In older versions there is no PASS 2..right?
And with this new PASS 2 detect keyword As as casting
which is really weird..right?
ok i will try right now... ;)
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 03:50:22 AM
Well with this dll error message is strange again ?
look in screenshot  :o


.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 24, 2014, 05:48:14 AM
Try this one. It will now report the line number, and include-file where the error occured.

It thinks that you are trying to "or" some string operands together :)

http://www.oxygenbasic.org/o2zips/Oxygen.zip
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 08:41:50 AM
Quote
It thinks that you are trying to "or" some string operands together

Charles i don't know , code for that part is the same ..nothing is changed
And how in the world work with older version ?

Ok i will try with new one again.

PS.IF again not work i will post complete code with old dll in which work that you can try
directly what is wrong ...
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 09:19:30 AM
Charles
something is very wrong with last dll because (as you can see from screenshot)
oxygen point in include file  Line :2674
But awinh.inc have only 1430 lines  :o
second
when i look into main code in line .2674 then
oxygen don't recognize operator OR in this line:
 
 While (Look = "*" Or Look = "/")

what is a nonsense ..right?
and i repeat work perfectly in older oxygen.dll ( not in last two release )
in attachment is source code so you can try compile...


.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 09:27:55 AM
And here is version of dll which work fine.
I really don't know which version is but i am sure that are not two latest.
 :-\


.
Title: Re: error with the latest Oxygen DLL
Post by: JRS on April 24, 2014, 09:40:27 AM
For Aurel.

(http://l.yimg.com/bt/api/res/1.2/xHstn8XAv3GS22jFMZrJPw--/YXBwaWQ9eW5ld3M7Zmk9ZmlsbDtoPTE4NztweW9mZj0wO3E9NzU7dz02MDA-/http://media.zenfs.com/en_us/News/ucomics.com/dt140424.gif)

Best part, Aurel will never appreciate the humor as translators don't work with images.  :)
Title: Re: error with the latest Oxygen DLL
Post by: Peter on April 24, 2014, 10:26:37 AM
Not bad,  John  ;D

 
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 12:57:25 PM
Yes work for that small example
but try compile ruben2 then tell me if compile ok on your computer?
and why compiler point on error in include file instead in main source ?

PS
Peter
This dll which work fine you post on my forum in OxyBasic package.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 24, 2014, 01:33:37 PM

Thanks for posting your source, Aurel. I am on the case.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 24, 2014, 01:39:51 PM
No problem Charles about that at all.
You will see that something is really ...really strange.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 25, 2014, 03:33:25 AM
Aurel,

This one compiles and runs your code as far as the "No Source" message.

Some of the expressions you use generate complex assembly code. So it's a good stress test for the compiler :)

http://oxygenbasic.org/o2zips/Oxygen.zip
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 25, 2014, 06:04:14 AM
Quote
Some of the expressions you use generate complex assembly code.
Heh...
I have just one parser routine and few processing functions.
This one which create problems is from expression evaluator which original version
is created in PureBasic.
(In PureBasic this evaluator work extremly fast, it looks that is PB very fast with strings)
Hmmm why i use this evaluator?
Simply because is fast and don't create memory leaks.
As i say before with DLL which i currently use work fine and properly.
This message 'No Source' is ok  ...so if you drag source file & drop into
this compiled exe(ruben2.exe)  program is executed.
ok time to try... ;)
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 25, 2014, 06:09:32 AM
Charles
When i try to download dll from a given link i get this error msg ...
do you change something?

.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 25, 2014, 09:30:56 AM
Sorry, it was meant to be zip rather than dll. Same as the previous.

I can see quite a few ways of boosting performance. For instance getting the next ascii code instead of getchar. Evaluating integers is much faster.

Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 25, 2014, 10:19:22 PM
Quote
Evaluating integers is much faster

Hi Charles
Yes i agree But i already tried to implement your evaluator which is from my opinion
great but produce somehow mem leaks .
Only this evaluator don't produce mem leak ..how or why i don't know.
Maybe some sort of combination will work faster without leak ..

Anyway ...thank you very much on new DLL  ;)
In attachment is a interpreter with few programs just to test Drag & Drop execution
 :)

.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 26, 2014, 06:24:29 AM
Anyone ...
is drag & drop work on your computer or not ?
thanks
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 26, 2014, 08:18:04 AM
Hi Aurel,

yes that is working nicely on Vista, thanks.

I'll see what can be done with Ascii vs Chars. It is easier to make gradual changes, rather than do something radical.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 26, 2014, 09:00:15 AM
Quote
I'll see what can be done with Ascii vs Chars. It is easier to make gradual changes, rather than do something radical.

Yes i agree ,and you know this things far better than me.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 26, 2014, 01:36:26 PM

An example of string elimination, producing more efficient binary

Before:

Code: [Select]
Function GetNum() as float
'print "SUB->GETNUM"
  STRING Temp
 
    If Asc(look) > 47 and Asc(look) < 58  ' read chars as numbers
       'print "need number"
    End if

While (Asc(Look) > 47 And Asc(Look) < 58) Or Asc(Look) = 46' dec.point
Temp = Temp + Look
Gosub getchar
         'print "GetNum-TEMP:" + Temp
Wend
       
  Return Val(Temp)
End Function

After:

Code: [Select]
Function GetNum() as double
 'print "SUB->GETNUM"
  sys c
  byte *m=StreamPos-2+strptr(Stream)
  do
    select m
      case "."        : 'ok
      case "0" to "9" : 'ok
      case else       : exit do
    end select
    @m++
    c++
  end do
  if c
    StreamPos+=c-1
    GetChar
    return Val((bstring) @b)
  end if
End Function

GetChar is used to fit in with the rest of your program.

Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 26, 2014, 02:52:52 PM
I've just plugged a memory leak associated with returning the ascii or val of a string expression. It's very specific. Examples:

return val(s+t)

return asc( mid(s,i,1) )

Thanks for exposing it, Aurel.

direct link for Oxygen.dll:
http://www.oxygenbasic.org/o2zips/Oxygen.zip

Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 26, 2014, 02:54:26 PM
Hmm
I think that i understand ...you use byte pointer
Ok i will try ...thanks  :)
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 26, 2014, 02:57:04 PM
Charles...
I am confused now  ???
Is that mean that your method create memory leak
OR
you find memory leak in last DLL ?
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 26, 2014, 03:08:36 PM
It's a DLL fix. I found it by chance, when scruinising the Asm generated by string returns. The return jumped over the Temp-string garbage collector, instead of calling it.

It does not affect the code I posted above.
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 26, 2014, 03:25:41 PM
ok  ;)
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 27, 2014, 02:11:35 AM
sorry Charles
But now is something wrong with compiled exes...not only with ruben interpreter then also with
ASciEdit to...
it looks that is something in conflict with win api becuse application crush when event is
triggered..for example after FileDialog  or compile button is clicked.. ???
In package is old dll too.


And Charles
it looks that your version of GetNum not work
oxygen say ...there is no variable b
Code: [Select]
Function GetNum() as double
 'print "SUB->GETNUM"
  sys c
  byte *m=StreamPos-2+strptr(Stream)
  do
    select m
      case "."        : 'ok
      case "0" to "9" : 'ok
      case else       : exit do
    end select
    @m++
    c++
  end do
  if c
    StreamPos+=c-1
    GetChar
    return Val((bstring) @b)
  end if
End Function

I look again and replace b with m and again not work for api graphics
what is really strange  :o
then i replace this function with old and work  ???
very very weird ...


.
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 27, 2014, 02:54:35 AM
Yes, sorry, there's missing lines. My code-pruning was overdone.

byte *b
@b=@m

Code: [Select]
Function GetNum() as double
 'print "SUB->GETNUM"
  sys c
  byte *m=StreamPos-2+strptr(Stream)
  byte*b
  @b=@m
  do
    select m
      case "."        : 'ok
      case "0" to "9" : 'ok
      case else       : exit do
    end select
    @m++
    c++
  end do
  if c
    StreamPos+=c-1
    GetChar
    return Val((bstring) @b)
  end if
End Function

Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 27, 2014, 05:05:09 AM
Charles
When you say:
- producing more efficient binary

do you mean faster execution?

So i tried two graphic programs with new GetNum() and looks to me that is not
faster than is even slower..is that possible?

I will built right now timer function to test time of execution then  will see.
 ;)
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 27, 2014, 06:19:22 AM
After testing
difference are very small in execution but it looks that older DLL work
just a little bit faster then this new one.
it is not strange to me because execution of my small interpreter directly depend on
processing loop which read tokens from string array
so simply there is no significant speed up   :-\
Title: Re: error with the latest Oxygen DLL
Post by: Charles Pegge on April 27, 2014, 07:22:41 AM
Aurel,

Something strange happening when ShellExecute is invoked. Will investigate further.

With regard to performance, the strategy is to reduce the number of string operations, in favour of integer operations, so the CPU has less work to do. That function is only one part of your parser.

PS:

ShellExecute is innocent. The problem was in the FileDialog prototype.

Cleanup for FileDialog:

Defext was defined as 'long', is now  a string
Also using strptr for all string parameters.

FileDialog for awinh.inc
Code: [Select]
'FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )
Function FileDialog(String Dir, filter , Title , long Hwnd, Flags, string defext) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval

ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = strptr filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = strptr filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = strptr dir
ofn.lpstrTitle = strptr title
IF Flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
IF Flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = strptr defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL

' Execute the dialog box
IF Flags = 0 then retval = GetOpenFileName(ofn)
IF Flags = 1 then retval = GetSaveFileName(ofn)

Return filename

End Function
Title: Re: error with the latest Oxygen DLL
Post by: Aurel on April 27, 2014, 08:57:18 AM
Yes i also think that is something wrong with  shellExecute ...
so problem is in FileDialog  ::)
hmm how then work with old DLL ?

ok i will fix things in FileDialog
thanks  ;)