Dynamic Function Names?

Results 1 to 2 of 2

Thread: Dynamic Function Names?

  1. #1
    Join Date
    Dec 1969

    Default Dynamic Function Names?

    Does anyone know of a way to eval a string to call a function? I had success getting this this work in Visual Basic using the ScriptingObject, but I cannot get it to work in ASP...<BR><BR>Something like (yes I know there is no eval in vbscript):<BR><BR>Function myFunc1()<BR> response.write "Called Func<BR>"<BR>End Function<BR><BR>a = 1<BR>eval("Function" & a)

  2. #2
    Join Date
    Dec 1969

    Default Well, you are wrong...

    Since version 5.0, VBS *has* had EVAL and EXECUTE. See the docs.<BR><BR>HOWEVER...<BR><BR>That&#039;s a crappy way to code. It&#039;s a real drag on server performance. [If this is on an under-utilized server, then w.t.h., use it.]<BR><BR>Unless you have hundreds of these functions to worry about, you&#039;ll get a lot better performance out of SELECT CASE:<BR><BR>SELECT CASE a<BR> case 1<BR> Sub1<BR> case 2<BR> Sub2<BR> case 3 <BR> Sub3<BR> case else<BR> SubCleanUp<BR>End Select<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