Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - This is really bugging me ... referencing array
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

This is really bugging me ... referencing array

 Post Reply Post Reply
Author
aussiem8 View Drop Down
Groupie
Groupie


Joined: 23 February 2012
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote aussiem8 Quote  Post ReplyReply Direct Link To This Post Topic: This is really bugging me ... referencing array
    Posted: 27 April 2012 at 10:00am
Hi there experts

I spent most of last night googling and try to get this to work, and thought I should have posted here for advice.    I'm working on some changes for my website and can't seem to reference an array inside a subroutine within the same file. 

Here's what I have ...
> A simple two dimensional array is created from database (currently Excel, but will be MySQL when I learn more about them!)
> I have a series of if-then statements that run different reports
> Within each report, I need to filter data from the array then print to screen (ie. response.write)
> I'm using a Sub for the response.write code as it's the same each time and I thought this would be cleaner than repeating the same code within every if-then statement

The problem is that when it goes to the Sub, the array values are lost, so is there a way of referencing the array within the Sub?   I've also tried using a function as well, but can't get it to work and I don't want to use arguments to pass the array values.   I also didn't want the array to be recreated each time the Sub is called.

The code is quiet long and messy (so I didn't want to post it) but just wondering if this normal behaviour for arrays?  

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Poole
Status: Offline
Points: 9587
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2012 at 10:04am
You could try either creating the array variable as a global variable creating it outside any function or sub, could pass the array to a new variable within the sub when calling the sub.
Back to Top
aussiem8 View Drop Down
Groupie
Groupie


Joined: 23 February 2012
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote aussiem8 Quote  Post ReplyReply Direct Link To This Post Posted: 27 April 2012 at 12:31pm
Thanks Bruce - I think I can make it work thanks to your suggestions.



Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.


Become a Fan on Facebook Follow us on Twitter Connect with us on LinkedIn Community Forums Web Wiz Blogs Web Wiz News
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2019 Web Wiz Ltd. All rights reserved.