![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi there,
the backward compatibility issue list of B4PPC6 says "Arrays cannot be passed and returned from subs.". Thus my prgram fails when trying to do "optimized compilation". Is there any way to work around this? Below see the code that fails - actually taken from the demo app "GPS4PPC". When compiling the app, I receive an error "CS0266: Cannot implicitly convert type 'object' to 'string'..." on the line where it says "return res()". Is there anything I can do except of declaring these variables global? Thanks, Frank Sub Distance_Course (lat1,lon1,lat2,lon2) ErrorLabel(Distance_CourseErr) lat1 = lat1 * cPI / 180 lon1 = -lon1 * cPI / 180 lat2 = lat2 * cPI / 180 lon2 = -lon2 * cPI / 180 d = 2 * ASin(Sqrt((Sin((lat1-lat2)/2))^2 + Cos(lat1)*Cos(lat2)*(Sin((lon1-lon2)/2))^2)) res.Distance = d * 180 * 60 /cPI If Cos(lat1) < 1e-7 Then If (lat1 > 0) Then tc1 = cpi Else tc1= 2*cpi End If Else sn = Sin(lon2-lon1) If Abs(sn) < 1e-7 Then If lat1 > lat2 Then tc1 = cpi Else tc1 = 2*cpi Else If sn < 0 Then tc1=ACos((Sin(lat2)-Sin(lat1)*Cos(d))/(Sin(d)*Cos(lat1))) Else tc1=2*cpi-ACos((Sin(lat2)-Sin(lat1)*Cos(d))/(Sin(d)*Cos(lat1))) End If End If res.Course = tc1 * 180 / cPI Return res() Distance_CourseErr: res.Distance = 0 res.Course = 0 Return res() End Sub
__________________
---------------------------- Frank (with XDA Orbit) |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing a value back from a dll | Ricky D | Questions & Help Needed | 2 | 10-25-2008 10:00 AM |
| Passing arrays to Subs. | jesb4ppc | Questions & Help Needed | 6 | 04-15-2008 06:03 PM |
| Filling 2-D arrays. | grgczyz | Basic4ppc Wishlist | 1 | 02-14-2008 12:38 PM |
| Filling arrays | Erel | Code Samples & Tips | 3 | 01-13-2008 06:11 PM |
| Arrays of any size | Gale Johnson | Code Samples & Tips | 5 | 08-17-2007 05:55 AM |