eval to execute - sub - Please Help. 
Author Message
 eval to execute - sub - Please Help.

Dear Reader thanks in advance for any help/recommendations.

Below is a sub that checks the quantity of an item in his/her shopping
basket against the qty in stock.

Problem is I can't use eval on the service providers server, VBScript
engine not V5. ????!!!!!

Usually I wouldn't have to pass the RecordSet name but in one case I
need to print and check stock of 3 Product tables.

Can any 1 think of a better way to do the same thing?
I've being trying with execute "function_in_a_string" with absolutly
NO luck, it won't "call makeButton".

dim inBasket,searchArray,tempBasket
sub checkCanBuy (recordset)    
        tempBasket=session("da01cart")                
        searchArray=""
        inBasket=0
        for i=lbound(tempBasket) to ubound(tempBasket)
                searchArray=searchArray &"*"& tempBasket(i,0) &"*"
                if inBasket=0 and InStr(searchArray,"*"&
eval(recordset)("productid") &"*")>0 then
                        inBasket=tempBasket(i,1)
                end if
        next

        if eval(recordset)("stock")=0 or
(eval(recordset)("stock")-inBasket)<1 then
                call makeButton("notify.asp?productid="&
eval(recordset)("productid") &"&name="& eval(recordset)("name"),"Sold
Out")
        else
                call makeButton("addprod.asp?productid="&
eval(recordset)("productid") &"&action=buy","Add To Basket")
        end if
end sub

Thanks again!!!



Thu, 30 Sep 2004 00:42:56 GMT  
 eval to execute - sub - Please Help.
I'm confused ;-)...

If the checkCanBuy sub is passed a reference to a recordset object, I don't see the purpose of

-> eval(recordset)("fieldname")

within the logic in checkCanBuy... Is there a reason why you don't simply do

-> recordset("fieldname")

directly?

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--

Quote:

> Dear Reader thanks in advance for any help/recommendations.

> Below is a sub that checks the quantity of an item in his/her shopping
> basket against the qty in stock.

> Problem is I can't use eval on the service providers server, vbscript
> engine not V5. ????!!!!!

> Usually I wouldn't have to pass the RecordSet name but in one case I
> need to print and check stock of 3 Product tables.

> Can any 1 think of a better way to do the same thing?
> I've being trying with execute "function_in_a_string" with absolutly
> NO luck, it won't "call makeButton".

> dim inBasket,searchArray,tempBasket
> sub checkCanBuy (recordset)
> tempBasket=session("da01cart")
> searchArray=""
> inBasket=0
> for i=lbound(tempBasket) to ubound(tempBasket)
> searchArray=searchArray &"*"& tempBasket(i,0) &"*"
> if inBasket=0 and InStr(searchArray,"*"&
> eval(recordset)("productid") &"*")>0 then
> inBasket=tempBasket(i,1)
> end if
> next

> if eval(recordset)("stock")=0 or
> (eval(recordset)("stock")-inBasket)<1 then
> call makeButton("notify.asp?productid="&
> eval(recordset)("productid") &"&name="& eval(recordset)("name"),"Sold
> Out")
> else
> call makeButton("addprod.asp?productid="&
> eval(recordset)("productid") &"&action=buy","Add To Basket")
> end if
> end sub

> Thanks again!!!



Thu, 30 Sep 2004 04:40:55 GMT  
 eval to execute - sub - Please Help.
This is one of those examples when one looks at the problem too long
and becomes blind to the obvious.

Dumbo (me) was passing recordset as a String.

Thanks Michael, I can see again.


Quote:
> I'm confused ;-)...

> If the checkCanBuy sub is passed a reference to a recordset object, I
> don't see the purpose of

> -> eval(recordset)("fieldname")

> within the logic in checkCanBuy... Is there a reason why you don't
> simply do

> -> recordset("fieldname")

> directly?

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US
> --


> > Dear Reader thanks in advance for any help/recommendations.

> > Below is a sub that checks the quantity of an item in his/her shopping
> > basket against the qty in stock.

> > Problem is I can't use eval on the service providers server, vbscript
> > engine not V5. ????!!!!!

> > Usually I wouldn't have to pass the RecordSet name but in one case I
> > need to print and check stock of 3 Product tables.

> > Can any 1 think of a better way to do the same thing?
> > I've being trying with execute "function in a string" with absolutly
> > NO luck, it won't "call makeButton".

> > dim inBasket,searchArray,tempBasket
> > sub checkCanBuy (recordset)
> > tempBasket=session("da01cart")
> > searchArray=""
> > inBasket=0
> > for i=lbound(tempBasket) to ubound(tempBasket)
> > searchArray=searchArray &"*"& tempBasket(i,0) &"*"
> > if inBasket=0 and InStr(searchArray,"*"&
> > eval(recordset)("productid") &"*")>0 then
> > inBasket=tempBasket(i,1)
> > end if
> > next

> > if eval(recordset)("stock")=0 or
> > (eval(recordset)("stock")-inBasket)<1 then
> > call makeButton("notify.asp?productid="&
> > eval(recordset)("productid") &"&name="&
>  eval(recordset)("name"),"Sold
> > Out")
> > else
> > call makeButton("addprod.asp?productid="&
> > eval(recordset)("productid") &"&action=buy","Add To Basket")
> > end if
> > end sub

> > Thanks again!!!



Thu, 30 Sep 2004 22:16:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. execute a variable as a function/sub procedure (like eval function in java(script))

2. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

3. PLEASE HELP PLEASE HELP PLEASE HELP

4. Using Functions and Subs?? Im new please help

5. Executing code that is stored in a table, Eval() function

6. Eval / Execute in vb.NET

7. execute and eval

8. execute() and eval()

9. Eval & Execute functions

10. Simulate VBScripts Execute and Eval in VB?

11. Faking functionality to VBScript Execute and JavaScript eval......

12. Execute/ Eval

 

 
Powered by phpBB® Forum Software