Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Passing arrays in B4PPC6?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-14-2008, 12:26 PM
Junior Member
 
Join Date: Sep 2007
Posts: 20
Default Passing arrays in B4PPC6?

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)
Reply With Quote
  #2 (permalink)  
Old 01-14-2008, 01:15 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

You can download the updated source code.

You to pass the arrays using global variables instead of the subs parameters.
Instead of:
Code:
SomeArray() = Distance_Course(...)
You should write:
Code:
Distance_Course(...)
SomeArray() = res()
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 01:09 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0