Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 storing and retrieving array information
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

klunde
Starting Member

Norway
26 Posts

Posted - 29 May 2001 :  04:06:27  Show Profile
Hi!

Could anyone help me with this:

I have a table with several fields where the first field is the variable name and the others are text in different languages. How do I create an array containging the first field and the field I specify so that I can call it later like response.write (array("variable")) (or something like it) to insert the correct text?



gor
Retired Admin

Netherlands
5511 Posts

Posted - 29 May 2001 :  04:33:58  Show Profile  Visit gor's Homepage
You can't do that with an array, but you could use the dictionary object.
See: http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/vsobjdictionary.htm

Pierre
Join the Snitz WebRing
Go to Top of Page

camusflage
Starting Member

USA
26 Posts

Posted - 29 May 2001 :  07:27:53  Show Profile
Just a quick note about the dictionary object.. If your host has disallowed the use of FSO by unregistering scrrun.dll, the dictionary object will be unavailable to you as well as it lives in the same dll. If, howver, they've simply modified launch and access permissions against FSO, you should be cool with it.

Mike



Go to Top of Page

klunde
Starting Member

Norway
26 Posts

Posted - 31 May 2001 :  01:39:17  Show Profile
Hmm... Thanks! maybe I should look into that.

But for the time being I've done it this way:


' GetLanguageStrings:
' Returns an array with all text strings for users selected language
Function GetLanguageStrings(adoCon)
If sid <> 0 Then ' User is logged in
set rslang = SQLQuery(adoCon, "SELECT lang FROM languages WHERE lang_id =" & Usr(adoCon, sid, "lang"))
langtext = rslang("lang")
Set RS = SQLQuery(adoCon, "SELECT variable, " & langtext & " FROM tblLanguage")
Else
Set RS = SQLQuery(adoCon, "SELECT variable, " & Application("lhd_SysLng") & " FROM tblLanguage")
End If
Select Case RS.eof
Case False
RSArray = RS.getrows
session("lhd_Language") = RSArray
'RSArray(Field, Record)
Case True
Response.Write "No Records were found"
End Select
RS.Close
End Function


'LANG
'Returns the textstring for the given language variable
Function lang(strVar)
LangArray = session("lhd_language")
Number_Of_Records = Cdbl(UBound(LangArray, 2))
For R = 0 to Number_Of_Records
if ucase(LangArray(0,R)) = ucase(strVar) then
lang = LangArray(1,R)
exit for
end if
Next
if len(lang) = 0 then
lang = "Text is missing in language table!"
end if
End Function


Then I can use lang("name_of_variable")

was this a bad idea?

--
Morten

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07