This code crashes Pb for some reason

Started by Draco9898, July 29, 2007, 12:58:46 AM

Previous topic - Next topic

Draco9898

TYPE tlinks
X#,Y#
lastX#,LastY#
ENDTYPE
DIM links(90) AS tlinks




DO
CLS 0
FOR x=0 TO GETARRAYELEMENTS(links().tlinks,1)
links(x).lastX#=links(x).X#
links(x).lastY#=links(x).Y#
IF X>0
X# = links(x-1).X#
ELSE
X# = (MOUSEX() - links(x).lastX#+36)/20


Y# = (MOUSEY() - links(x).lastY#)/20
links(x).y# = links(x).y# + y#
ENDIF
      `links(x).X# = links(x).X# + X#
`this above line uncommented will strangely cause PB to crash on 1.63(g?), compiler 1.1.5f

CIRCLE links(x).X#,links(x).y#,15,1
NEXT x

SYNC
LOOP


I was playing with something similar that involved reading previous array indexes (x -1) and got a blue screen, I obviously couldn't save the code :/
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


If you pause the code each loop, you'll see it causes the floating point unit in the cpu to overflow... Which is bad ! 


TYPE tlinks
X#,Y#
lastX#,LastY#
ENDTYPE
DIM links(90) AS tlinks




DO
CLS 0
FOR x=0 TO GETARRAYELEMENTS(links().tlinks,1)
links(x).lastX#=links(x).X#
links(x).lastY#=links(x).Y#
IF X>0
X# = links(x-1).X#
ELSE
X# = (MOUSEX() - links(x).lastX#+36)/20


Y# = (MOUSEY() - links(x).lastY#)/20
links(x).y# = links(x).y# + y#
ENDIF

      links(x).X# = links(x).X# + X#

`this above line uncommented will strangely cause PB to crash on 1.63(g?), compiler 1.1.5f


print links(x).X#
CIRCLE links(x).X#,links(x).y#,15,1
NEXT x

SYNC
waitkey
waitnokey

LOOP




Draco9898

My fault or...? I cant see where I did anything ...wrong, per se...
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#3
Yours.   

See the X# values after each pass..  Clearly they don't make sense



Pass=========================================
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
1.8
Pass=========================================
25.51
27.31
29.11
30.91
32.71
34.51
36.31
38.11
39.91
41.71
43.51
45.31
47.11
48.91
50.71
52.51
54.31
56.11
57.91
59.71
61.51
63.31
65.11
66.91
68.71
70.51
72.31
74.11
75.91
77.71
79.51
81.31
83.11
84.91
86.71
88.51
90.31
92.11
93.91
95.71
97.51
99.31
101.11
102.91
104.71
106.51
108.31
110.11
111.91
113.71
115.51
117.31
119.11
120.91
122.71
124.51
126.31
128.11
129.91
131.71
133.51
135.31
137.11
138.91
140.71
142.51
144.31
146.11
147.91
149.71
151.51
153.31
155.11
156.91
158.71
160.51
162.31
164.11
165.91
167.71
169.51
171.31
173.11
174.91
176.71
178.51
180.31
182.11
183.91
185.71
187.51
Pass=========================================
48.0345
75.3445
104.454
135.365
168.074
202.584
238.894
277.004
316.914
358.624
402.134
447.444
494.554
543.464
594.174
646.684
700.994
757.104
815.014
874.724
936.234
999.544
1064.65
1131.56
1200.27
1270.78
1343.09
1417.2
1493.11
1570.82
1650.33
1731.64
1814.75
1899.66
1986.37
2074.88
2165.19
2257.3
2351.21
2446.92
2544.43
2643.74
2744.85
2847.76
2952.47
3058.98
3167.29
3277.4
3389.31
3503.02
3618.53
3735.84
3854.96
3975.87
4098.58
4223.09
4349.4
4477.51
4607.42
4739.13
4872.64
5007.95
5145.06
5283.97
5424.68
5567.19
5711.5
5857.61
6005.52
6155.23
6306.74
6460.05
6615.16
6772.07
6930.78
7091.29
7253.6
7417.71
7583.62
7751.33
7920.84
8092.15
8265.26
8440.17
8616.88
8795.39
8975.7
9157.81
9341.72
9527.43
9714.94