Execute Problem...

Results 1 to 3 of 3

Thread: Execute Problem...

  1. #1
    Join Date
    Dec 1969

    Default Execute Problem...

    I&#039;m using the below Function, and calling it like this....<BR><BR>ThisString = CreateCode("ASP", "Response.Write Now()")<BR><BR>It totally works, but instead of ThisString be equal to the value of the executed code, the code is just executed ("It writes out the date) but the ThisString variable never takes on the value.... Is there any way to get it to work the way I want it?<BR><BR>Thanks!<BR><BR>Function CreateCode(CodeType, CODE)<BR> If CodeType = "ASP" Then<BR> CreateCode = Execute(CODE)<BR> End If<BR>End Function

  2. #2
    Join Date
    Dec 1969

    Default RE: Execute Problem...

    Function CreateCode(CodeType, CODE) <BR> If CodeType = "ASP" Then <BR> Execute("CreateCode=" & CODE) <BR> End If <BR>End Function <BR><BR>Execute executes the code it&#039;s passed, as far as I know it doesn&#039;t return anything. So if you want to assign your results to a variable you need to include that assignment in what you&#039;re executing. Doing things this way incurrs additional overhead. What&#039;s your reason for wanting to do this?

  3. #3
    Join Date
    Dec 1969

    Default You should NEVER use Execute

    I have not yet ever found a single case where EXECUTE is necessary. I have found a bare handful of cases where it might even be useful.<BR><BR>You have no reason at all to use EXECUTE for this code.<BR><BR>All of that stuff you are doing can be changed to simply<BR> ThisString = CSTR( Now() )<BR><BR>And if you *also* want it to write out the date and time, then do it in two statements:<BR> ThisString = CSTR( Now() )<BR> Response.Write ThisString<BR><BR>I have a standing offer to buy a latte for anybody who can show me a *REAL* use for EXECUTE, one that can&#039;t be done any better way. So far, I&#039;ve had to pay off once. And that was only for a use while debugging programs, not while actually running in production mode. (By the way, there&#039;s a catch: You have to come to Seattle to collect. Naw...if you come up with a truly truly good one, I&#039;d pay off.)<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