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 references to tables to subs


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2007, 01:12 AM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 117
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, 06:44 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,132
Default

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

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

See this example: Runtime control manipulation
Reply With Quote
  #3 (permalink)  
Old 05-31-2007, 07:23 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
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
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 05-31-2007, 08:42 AM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 117
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, 12:44 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
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
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #6 (permalink)  
Old 05-31-2007, 09:27 PM
LineCutter's Avatar
Senior Member
 
Join Date: May 2007
Location: Daarsit
Posts: 117
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
IDE subs list width klaus Beta Versions 1 09-28-2008 04:56 AM
Passing arrays to Subs. jesb4ppc Questions & Help Needed 6 04-15-2008 06:03 PM
Redundant SUBs badkarma Basic4ppc Wishlist 0 04-10-2008 08:50 PM
How to use timer to clock speed of subs? Stellaferox Questions & Help Needed 4 02-28-2008 08:07 AM
control references jireland Basic4ppc Wishlist 2 12-29-2007 01:41 AM


All times are GMT. The time now is 02:53 PM.


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