I have started messing around with PB2DLL at long last and seem to have come across a problem.
i have translated this to PD2DLL
[pbcode]
;do ;x,y ,rad,split,rad2
; DLL_circ(rndrange(100,700),rndrange(100,500),rnd(50),rnd(10),5)
;sync
; loop
Function DLL_circ(x#,y#,rad#,split#,rad2#)
ink rgb(rnd($ff),rnd($ff),rnd($ff))
local r#,ox#,oy#,nx#,ny#
ox#=cos(r#)*rad#
oy#=sin(r#)*rad#
for r#=0 to 360 step split#
nx#=cos(r#)*rad#
ny#=sin(r#)*rad#
line x#+ox#,y#+oy#,x#+nx#,y#+ny#
ic(x#+nx#,y#+ny#,rad2#)
ox#=nx#
oy#=ny#
; sync
next
EndFunction
Function ic(x#,y#,rad#)
local r,ox#,oy#,nx#,ny#
ox#=cos(r)*rad#
oy#=sin(r)*rad#
for r=0 to 360 step 10
nx#=cos(r)*rad#
ny#=sin(r)*rad#
line x#+ox#,y#+oy#,x#+nx#,y#+ny#
ox#=nx#
oy#=ny#
; sync
next
EndFunction
[/pbcode]
i call the dll with
[pbcode]linkDll "C:\Users\PC\Desktop\pb stuff\dll testing\dll3\dll\unnamed.dll"
circ(x#,y#,rad#,split#,rad2#) alias "circ"
EndlinkDll
local it=0
do
circ(rndrange(100,700),rndrange(100,500),rnd(50),rnd(10),5)
it++
print it
sync
loop
[/pbcode]
i find that it only runs for a random amount of iterations,max 15 loops before freezing whereas the original code runs fine
you can test the original code by uncommenting the first 4 lines and run it in PB
Looking at the test code I suspect your problem is an infinite loop stemming from this call,
circ(rndrange(100,700),rndrange(100,500),rnd(50),rnd(10),5)
If you call the dll version of the function and split# parameter is zero, then the you've created an infinite loop. So it'll loop inside the function forever.
This works in the run times as they have code in them to trap these sort of things and automatically exit.
Here's slight tune up of the code.
[pbcode]
Function DLL_circ(x#,y#,rad#,split#,rad2#)
; should really preserve the ink colour before changing it here
ink rndrgb()
local r#,ox#,oy#,nx#,ny#
ox#=x#+cos(r#)*rad#
oy#=y#+sin(r#)*rad#
lockbuffer
for r#=0 to 360 step split#
nx#=x#+cos(r#)*rad#
ny#=Y#+sin(r#)*rad#
line ox#,oy#,nx#,ny#
ic(nx#,ny#,rad2#)
ox#=nx#
oy#=ny#
next
unlockbuffer
EndFunction
[/pbcode]
ahha!
Thanks for that Kevin.
I changed rnd(10) TO rndrange(1,10)
and now it works like a charm!
this seems to happen on exit fairly often
Thanks for the heads up, but unfortunately those dialogs aren't at all useful remotely.
What I need are things like the your log files, the source your building in order to try and replicate the problems.
Another strange point is if i pin PB2DLL to my taskbar windows always informs me that the shortcut is invalid.
I think it may be something to do with the dialogues again as it only happens when i select a file and not when i choose one from the history list.
This is the code i am putting through PB2DLL
LogFile Attached
Quote; PROJECT : dlltest3
; AUTHOR : PC
; CREATED : 05/07/2014
; EDITED : 10/07/2014
; ---------------------------------------------------------------------
explicit on
Constant makedll=1
#if not makedll
local it,avg,t#=timer()
do
DLL_circ(rndrange(100,700),rndrange(100,500),100,5,5);rndrange(1,10),5)
it++
if it>1000
cls
print (timer()-t#)/1000
sync
repeat
until spacekey()
flushkeys
end
endif
boxc 0,0,50,20,1,0
avg=((timer()-t#))/it
text 0,0,str$(it)+" "+str$((timer()-t#)/1000)+" "+str$(avg)
sync
loop
#endif
Function DLL_circ(x#,y#,rad#,split#,rad2#)
static count
ink rgb(rnd($ff),rnd($ff),rnd($ff))
local r#,ox#,oy#,nx#,ny#
ox#=cos(r#)*rad#
oy#=sin(r#)*rad#
for r#=0 to 360 step split#
nx#=cos(r#)*rad#
ny#=sin(r#)*rad#
line x#+ox#,y#+oy#,x#+nx#,y#+ny#
ic(x#+nx#,y#+ny#,rad2#)
ox#=nx#
oy#=ny#
next
count ++
ink $ffffff
boxc 0,0,100,20,1,0
text 0,0,count
EndFunction
Function ic(x#,y#,rad#)
local r,ox#,oy#,nx#,ny#
ox#=cos(r)*rad#
oy#=sin(r)*rad#
for r=0 to 360 step 360/36
nx#=cos(r)*rad#
ny#=sin(r)*rad#
line x#+ox#,y#+oy#,x#+nx#,y#+ny#
ox#=nx#
oy#=ny#
next
EndFunction
Thanks, but given what's in your log files, I was expecting you to email it.. Thus have deleted the file from the previous post.
Without looking at it, I suspect the issue is that somewhere a bank of memory is being prematurely deleted. Have ran into a similar with Amos2PB..