Author Topic: Classes, Unions and Arrays Help Please  (Read 20512 times)

0 Members and 1 Guest are viewing this topic.

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #60 on: June 18, 2012, 08:04:52 PM »
This is a new one Charles. Actually in older speed tests I tested those and they were not that much of a hit. The += of a string is the real slow down and it seems to get longer as the amount additions take place.

Can you show how a dynamic string array can be passed to a method in another class? Or how a dynamic string array that is filled with date can be dumped to a string quickly with += ?

Charles Pegge

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #61 on: June 18, 2012, 08:58:46 PM »
Hi Kent,

Using a string buffer avoids the problem of accumulative concatentation. This demo generates a string of 100 million bytes, built from 10 million strings.

On my PC, it takes less than a second.

Code: OxygenBasic
  1.  
  2. Class StringBuffer
  3.  
  4. string Buf
  5. sys    i,le
  6.  
  7. method constructor(sys lb=1000)
  8.   buf=nuls lb
  9.   le=lb
  10.   i=0
  11. end method
  12.  
  13. method destructor()
  14.   buf=""
  15.   i=0
  16.   le=0
  17. end method
  18.  
  19. method add(string s)
  20.   sys ls=len s
  21.   if i+ls>le then
  22.     buf+=nuls le+ls 'extend buffer
  23.    le+=le+ls
  24.   end if
  25.   mid buf,i+1,s
  26.   i+=ls
  27. end method
  28.  
  29. method get() as string
  30.   return left(buf,i)
  31. end method
  32.  
  33. end class
  34.  
  35. 'TEST
  36. '====
  37.  
  38. new StringBuffer b(1e8)
  39.  
  40. for i=1 to 1e7
  41.   b.add "0123456789"
  42. next
  43.  
  44. print mid(b.buf,i-9,10) " : length of string: " b.i
  45.  
  46. del b
  47.  
  48.  

Charles

Charles Pegge

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #62 on: June 18, 2012, 09:11:38 PM »
Easy way to pass a string array:

Code: OxygenBasic
  1.  
  2. 'Passing string array
  3.  
  4. function f(sys p,n)
  5. string s at p
  6. string pr
  7. sys i
  8. for i=1 to n
  9.   pr+=s[  i  ]
  10. next
  11. print pr
  12. end function
  13.  
  14.  
  15. string s[10]
  16.  
  17. for i=1 to 10
  18.   s[ i ]=chr(i+64)
  19. next
  20.  
  21. f(@s,10)
  22.  

Charles

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #63 on: June 24, 2013, 10:47:01 PM »
Hi Kent,

Using a string buffer avoids the problem of accumulative concatentation. This demo generates a string of 100 million bytes, built from 10 million strings.

On my PC, it takes less than a second.

Code: OxygenBasic
  1.  
  2. Class StringBuffer
  3.  
  4. string Buf
  5. sys    i,le
  6.  
  7. method constructor(sys lb=1000)
  8.   buf=nuls lb
  9.   le=lb
  10.   i=0
  11. end method
  12.  
  13. method destructor()
  14.   buf=""
  15.   i=0
  16.   le=0
  17. end method
  18.  
  19. method add(string s)
  20.   sys ls=len s
  21.   if i+ls>le then
  22.     buf+=nuls le+ls 'extend buffer
  23.    le+=le+ls
  24.   end if
  25.   mid buf,i+1,s
  26.   i+=ls
  27. end method
  28.  
  29. method get() as string
  30.   return left(buf,i)
  31. end method
  32.  
  33. end class
  34.  
  35. 'TEST
  36. '====
  37.  
  38. new StringBuffer b(1e8)
  39.  
  40. for i=1 to 1e7
  41.   b.add "0123456789"
  42. next
  43.  
  44. print mid(b.buf,i-9,10) " : length of string: " b.i
  45.  
  46. del b
  47.  
  48.  

Charles

This is giving an error now Charles, as of June 2013.

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #64 on: June 24, 2013, 10:49:55 PM »
This is also giving an error now.

Easy way to pass a string array:

Code: OxygenBasic
  1.  
  2. 'Passing string array
  3.  
  4. function f(sys p,n)
  5. string s at p
  6. string pr
  7. sys i
  8. for i=1 to n
  9.   pr+=s[  i  ]
  10. next
  11. print pr
  12. end function
  13.  
  14.  
  15. string s[10]
  16.  
  17. for i=1 to 10
  18.   s[ i ]=chr(i+64)
  19. next
  20.  
  21. f(@s,10)
  22.  

Charles


Charles Pegge

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #65 on: June 25, 2013, 12:27:01 AM »
Hi Kent,

Both of these work on my PC. Is your system launching the right Oxygen?

Peter

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #66 on: June 25, 2013, 01:37:09 AM »
Quote
Class StringBuffer
 

Runs!
It needed 10 seconds here!

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #67 on: June 25, 2013, 10:48:21 AM »
Hi Kent,

Both of these work on my PC. Is your system launching the right Oxygen?

I downloaded and am running from the in progress zip here:
http://www.oxygenbasic.org/o2zips/OxygenBasic.zip

Will redownload and try again just to make sure all is OK.

Update: Redownloaded and still get errors. Will look for the oxygen.dll update on the forums next.
update2:downloaded from here and still get errors. http://www.oxygenbasic.org/forum/index.php?topic=749.0
update3:Deleted everything. Went in regedit and deleted all oxygen and scite entries. Reinstalled in progress OxygenBasic.
Still getting this error running the shorter code example for string array passing:
>"C:\Dev\OxygenBasic\gxo2" " -c StringArrayAsParameter.o2bas"

     pr + = [edi]!!  Unidentified instruction:   pr
 ; AFTER:     ._c
 ; LINE:       9



>Exit code: 0
« Last Edit: June 25, 2013, 11:26:59 AM by kryton9 »

Charles Pegge

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #68 on: June 25, 2013, 12:17:31 PM »
What happens if you execute:

print 0x80000000<<<2

Aurel

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #69 on: June 25, 2013, 12:21:52 PM »
Kent
where is this example...?

Peter

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #70 on: June 25, 2013, 12:42:30 PM »
Quote
pr + = [edi]!!  Unidentified instruction:   pr

Runs!
Code: [Select]
indexbase 0

sys rolled, pr=100
'print 32<<<2

'mov  eax,32
'rol  eax,2
'mov  rolled,eax
'print rolled

mem= getmemory 100
 
mov  al,255
mov  edi,mem
mov  [edi],al

pr += [edi]
print pr     ' pr=355

JRS

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #71 on: June 25, 2013, 01:33:39 PM »
I'm sure you have already done this but is there a chance an older version of Oxygen.dll is defined earlier in your search path? (syswow64 ???)

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #72 on: June 25, 2013, 01:46:02 PM »
What happens if you execute:

print 0x80000000<<<2


Avast popped up, I gave it permission and it ran and printed -1.

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #73 on: June 25, 2013, 01:46:46 PM »

kryton9

  • Guest
Re: Classes, Unions and Arrays Help Please
« Reply #74 on: June 25, 2013, 01:54:17 PM »
I'm sure you have already done this but is there a chance an older version of Oxygen.dll is defined earlier in your search path? (syswow64 ???)

I checked my environment path variables, cleaned up the registry of any scite or oxygen entries. That is why I am stumped.