Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Passing references to tables to subs

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2007, 12:12 AM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 161
Awards Showcase
Beta Tester 
Total Awards: 1
Question Passing references to tables to subs

Time for another one...
I'm trying to keep my code neat & small. I need to process data held in a table in one of my subs. BUT, I have several copies of the table schema, all holding different set of data & I want to process one dataset. (Merging the datasets does not seem a good idea, unless I've missed a trick when it comes to saving tables)

How do I pass a table ID as a parameter to a sub, such that I can use <tableID>.cell() etc. within the sub?
Reply With Quote
  #2 (permalink)  
Old 05-31-2007, 05:44 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You should use the Control keyword.
For example:
DoSomething ("Table1")

Sub DoSomething (TableName)
Control(TableName).LoadCSV...
End Sub

See this example: http://www.basic4ppc.com/forum/code-samples-tips/128-runtime-control-manipulation.html
Reply With Quote
  #3 (permalink)  
Old 05-31-2007, 06:23 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Dependant on what you are doing with the tables i.e. if all of the data set have been created, then you can just access the cells directly.
Tables and all other controls are Global objects.

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 05-31-2007, 07:42 AM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 161
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks Erel, that was the thing I was after. I must have missed that thread from the 10th somehow - I searched the docs, but missed the right keyword.

RandomCoder: Thanks too. The tables could be accessed specifically, but I'd then need 3 (at least) subs to do the job, all differing only in the table name used inside them.
Reply With Quote
  #5 (permalink)  
Old 05-31-2007, 11:44 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
The tables could be accessed specifically, but I'd then need 3 (at least) subs to do the job, all differing only in the table name used inside them.
LineCutter,

I think you misunderstand me, I was meaning to load all three tables with data but then use just one sub to access whichever cells you require, something like...

Sub DoSomeThing(TabelName,ColName,RowNumber)
CellData=Control(TableName).Cell(ColName,RowNumber )
...
...
End Sub

This would be quicker than having to load the data into a single table each time you want to access a cell. Of course I don't know what you are populating the tables with or even whether you need to access data from more than one of the tables during normal operation. It's just another idea to add to the pot

Regards,
RandomCoder
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #6 (permalink)  
Old 05-31-2007, 08:27 PM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 161
Awards Showcase
Beta Tester 
Total Awards: 1
Default

RandomCoder, we're saying the same thing
The plan is to use DoStuff(table,filter) to process temptable or authorisedtable. Obviously, with the same table format I can use the same sub. At the end of the day it's only authorisedtable that needs saving, which is why I want them separated.
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing arrays to Subs. jesb4ppc Questions (Windows Mobile) 12 04-24-2009 09:05 AM
IDE subs list width klaus Beta Versions 1 09-28-2008 03:56 AM
How to use timer to clock speed of subs? Stellaferox Questions (Windows Mobile) 4 02-28-2008 07:07 AM
control references jireland Basic4ppc Wishlist 2 12-29-2007 12:41 AM


All times are GMT. The time now is 07:52 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0