Print Page | Close Window

This is really bugging me ... referencing array

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=30296
Printed Date: 01 October 2023 at 9:06am
Software Version: Web Wiz Forums 12.06 - https://www.webwizforums.com


Topic: This is really bugging me ... referencing array
Posted By: aussiem8
Subject: This is really bugging me ... referencing array
Date 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?  




Replies:
Posted By: WebWiz-Bruce
Date 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.

-------------
http://www.facebook.com/WebWiz" rel="nofollow - Find Web Wiz on Facebook
http://twitter.com/WebWizUK" rel="nofollow - Follow Web Wiz on Twitter


Posted By: aussiem8
Date Posted: 27 April 2012 at 12:31pm
Thanks Bruce - I think I can make it work thanks to your suggestions.






Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.06 - https://www.webwizforums.com
Copyright ©2001-2023 Web Wiz Ltd. - https://www.webwiz.net