如何在有和没有分配变量的情况下调用Single Classic ASP参数化函数?没有CALL

时间:2017-10-11 07:58:42

标签: function variables vbscript asp-classic

我在Classic Asp中定义了一个带有参数的函数,返回值。

在不使用CALL

的情况下调用两次经典ASP功能
  

1.存储返回值

     

2.不存储返回值(不像CALL功能名称)

 Function concatenate(first, last, operation)
    Dim full
    full = first & last
    IF operation="I" THEN
      'Storing the value in database and returning Result Set
       concatenate = conn.Execute(full)
    END IF
    IF operation="U" THEN
      'Updating the value in database without returning Result Set
       conn.Execute(full)
    END IF
  End Function

  ' Here is the usage of returning value from function. 
  dim rs
  SET rs= concatenate("First", "Last", "I") 'Executing Correctly
  CALL concatenate("First", "Last", "I")    'Executing But not my requirement Because need to change many times Cause by Just adding a Parameter
  concatenate("First", "Last", "U")          'Compilation Error

如何在不存储值的情况下调用相同的函数。 关于经典ASP功能

,请帮助我

1 个答案:

答案 0 :(得分:1)

这里有很多错误信息,你不需要改变函数内部的任何内容,函数可以根据你的调用方式返回一个值。

'Don't return a value
 concatenate "First", "Last", "U"

 'If you still want to call with parentheses
 Call concatenate("First", "Last", "U") 

如果您想知道为什么会有效;

'What no "cannot use parentheses" error??
concatenate("First")

然后这里有一些轻松的阅读。