Hello, i'am new to purebasic and to the fourms and i been playing around with pb and i found that some lines of code don't work in some places
inparticular, lines that return to a varibal
i have to find one because i found a work around to them
but it just annoying becuase it will return one number like it was a constant it can only set once and then never change but it does not give any errors what so ever
if any one has found this problem before please tell me if this is a bug or something i doing wrong
werid problem
werid problem
~Dreglor
Lets see some code! 
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
sorry it took so long but i found it
i had forgoten what i got it from
i try it again it it does it work
but if i use a diffrent (but identical resulting) line of code it works perfectly
i have tested this in a diffrent lang and it works just fine...
heres the code:
the one that doesn't work only out puts 255
and can any one verify that my fps counter work properly?
so if any one spot why this isn't working i would love to know why it happing and if it should do that
i had forgoten what i got it from
i try it again it it does it work
but if i use a diffrent (but identical resulting) line of code it works perfectly
i have tested this in a diffrent lang and it works just fine...
heres the code:
Code: Select all
If InitSprite()=0
MessageRequester("Fatal Error!","Could not initalize directX",0)
End
EndIf
#screen_width.w=1024
#screen_height.w=768
If OpenScreen(#screen_width,#screen_height,16,"")=0
MessageRequester("Fatal Error!","Could not initalize the screen",0)
End
EndIf
If InitKeyboard()=0
MessageRequester("Fatal Error!","Could not initalize the keyboard",0)
End
EndIf
SetFrameRate(60) ;i put this in to keep the frame rate constant
xmax.w=10000
ymax.w=10000
zmax.w=2000
sspeed.w=-10
zmin.w=10
num.l=5000 ;get slow around 55000-60000 and i have 2.66 cpu ( by slow i mean if it gets below 60 fps, the set frame rate)
centerx.w=#screen_width/2
centery.w=#screen_height/2
zoom.w=60
shade.w=0
fnum.w=0
fps.s="0"
Dim sx(num)
Dim sy(num)
Dim sz(num)
For i=0 To num
sx(i)=Random(xmax)-xmax/2
sy(i)=Random(ymax)-ymax/2
sz(i)=Random(zmax)
Next i
Repeat
StartDrawing(ScreenOutput())
start=Date()
For i=0 To num
sz(i)=sz(i)+sspeed
If sz(i)<=zmin
sz(i)=zmax
sx(i)=Random(xmax)-xmax/2
sy(i)=Random(ymax)-ymax/2
EndIf
screenx.w=(sx(i)*zoom)/sz(i)+centerx
screeny.w=(-sy(i)*zoom)/sz(i)+centery
shade=255-(sz(i)/zmax*255) ;does'nt work always returns 255 i don't know why
;shade=Int(255/zmax* -sz(i)) ;does work
If screenx < #screen_width
If screeny < #screen_height
If screenx > 0
If screeny > 0
Plot(screenx,screeny,RGB(shade,shade,shade))
EndIf
EndIf
EndIf
EndIf
Next i
DrawText("FPS: "+fps)
StopDrawing()
FlipBuffers()
ClearScreen(0,0,0)
ExamineKeyboard()
If Date() > start
fps=Str(fnum)
fnum=0
start=Date()
Else
fnum=fnum+1
EndIf
Until KeyboardReleased(#PB_Key_Escape)
CloseScreen()
End
and can any one verify that my fps counter work properly?
so if any one spot why this isn't working i would love to know why it happing and if it should do that
~Dreglor
To summarise, all you have to do to fix the original line is change line 25 to
Alternatively you can wrap the bad line in an Int(), just like the good line.
Interestingly, if you remove the Int() from the good line, it now fails but this time the result is always 0, so you see nothing unless you change the background colour.
If you are assigning to a variable then that target seems to be used for storing interim results. This probably saves having to allocate new memory locations so it could be a deliberate optimisation.
When the expression is destined for a function call, then that calls paramater is the target paramater.
Here's a demonstration:
returns
Code: Select all
shade.f=0
Interestingly, if you remove the Int() from the good line, it now fails but this time the result is always 0, so you see nothing unless you change the background colour.
If you are assigning to a variable then that target seems to be used for storing interim results. This probably saves having to allocate new memory locations so it could be a deliberate optimisation.
When the expression is destined for a function call, then that calls paramater is the target paramater.
Here's a demonstration:
Code: Select all
Procedure.l lParam(p.l)
ProcedureReturn p * 100
EndProcedure
Procedure.f fParam(p.f)
ProcedureReturn p * 100
EndProcedure
l.l = (10/3) * 100
f.f = (10/3) * 100
Debug l
Debug f
Debug lParam(10/3)
Debug fParam(10/3)
Code: Select all
300
333.333313
300
333.333313
You mean like Javascript? No no no... thats just lazy!so maybe purebsic does not have any datatype converting yet?



