APPLICATION VARIABLE THAT SETS 20 VARIABLES

Results 1 to 2 of 2

Thread: APPLICATION VARIABLE THAT SETS 20 VARIABLES

  1. #1
    Join Date
    Dec 1969
    Posts
    294

    Default APPLICATION VARIABLE THAT SETS 20 VARIABLES

    GREETINGS ALL,<BR><BR>I need to make an Application Variable that will contain 20 variables. <BR>It will be read only.<BR>anyone know the syntax ?? or have any ideas ? <BR><BR>I&#039m trying to create the most efficient way to set up the <BR>application variable to hold 20 variable (each containing the 20 same variable names but each holding different data) <BR>These 20 variables will be called and made available for use on the requesting ASP page. <BR><BR>Here is my idea. I know i&#039m really reaching. But if someone could help me <BR>figure this out i would be grateful. <BR><BR>My idea is to place application subroutines in the global.asa file that when <BR>called will set 20 variables equal to the proper data for instant use on that <BR>ASP page. <BR><BR> can someone tell me the proper way to do this ? Here is my Idea:<BR> &#060;SCRIPT LANGUAGE="VBScript" RUNAT="Server"&#062;<BR><BR>Sub Application_OnStart<BR> sub_num1()<BR> variable1="whatever"<BR> variable2="whenever"<BR> variable3="however"<BR> .........all the way to <BR> variable20="whoever"<BR> end sub <BR> set Application("selection_num_1")=sub_num_1( ) <BR> set Application("selection_num_2")=sub_num_2( ) <BR> set Application("selection_num_3")=sub_num_3( ) <BR> set Application("selection_num_4")=sub_num_4( ) <BR> set Application("selection_num_5")=sub_num_5( ) <BR> set Application("selection_num_6")=sub_num_6( ) <BR> set Application("selection_num_7")=sub_num_7( ) <BR> all the way down to 50<BR> set Application("selection_num_20")=sub num_50( )<BR><BR>site. <BR>End Sub <BR><BR>Is that correct. if not what is ? <BR>and Would those variables then be available for use in the requesting page ? ?

  2. #2
    Join Date
    Dec 1969
    Posts
    96,118

    Default RE: APPLICATION VARIABLE THAT SETS 20 VARIABLES

    &nbsp;<BR>Consider: There isn&#039t any such thing as an "Application Variable." That&#039s a "marketing named" used as a shortcut for<BR>"application-persistent value accessed by a hashvalued key."<BR><BR>In other words, the so-called "application variables" are *really* simply key/value pairs in a hashtable (perhaps more familiar to you as a "collection" or a "dictionary").<BR><BR>So why not simply take advantage of this and store all 400 of your values (you *did* say 20 sets of 20 named values, right?) as basic application values. A very little ingenuity in naming and you are done:<BR><BR>Application("Section 1 Subsection 1") = "...some value..."<BR>Application("Section 1 Subsection 2") = "...some value..."<BR>Application("Section 1 Subsection 3") = "...some value..."<BR>...<BR>Application("Section 1 Subsection 20") = "...some value..."<BR>Application("Section 2 Subsection 1") = "...some value..."<BR>Application("Section 2 Subsection 1") = "...some value..."<BR>...<BR>Application("Section 20 Subsection 20") = "...some value..."<BR><BR>So now you can access any of those values via<BR><BR>someVariable = Application("Section " & secnum & " Subsection " & subsecnum)<BR><BR>It has the advantage of being reasonably efficient and dirt simple.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •