|
Post by meerkat on Dec 18, 2008 9:39:43 GMT -5
For some reason the variable "cartItems$" causes a error message. If I use kartItems$ it works? Running this code fails. However if I comment out: 'cartItems$ = cartItems$;itemNum$;"|" it works.. if rows > 0 then kartItems$ = kartItems$;itemNum$;"|" cartItems$ = cartItems$;itemNum$;"|" numInCart = numInCart + 1 #row = #sql #nextrow() gosub [itemGetData] html "<script> document.getElementById('inCart').innerHTML = '" html "Total Items:";numInCart;" Added:";descr$ html "';</script>" end if
|
|
|
Post by Carl Gundel - admin on Dec 18, 2008 11:21:10 GMT -5
What kind of error are you talking about? The code you provide compiles fine, but of course since rows is not > 0 then nothing happens, but then the example doesn't provide an object for the #sql variable so it would break there if rows > 0.
-Carl
|
|
|
Post by meerkat on Dec 18, 2008 14:47:15 GMT -5
Here is the error I get: "This message is not appropriate for this object." I have on error traps and print the error from the error number. So this error don't look right to me..
I don't even know how to send the code that causes the problem. It's big, and would require a database and a RUNning program that RUNs the code with the problem.
The variable can be anything like cartItems$ or inCartItems$. As long as you get rid of the "C" it works. Such as kartItems$ or inKartItems$.
If you are interested I can give you a link to the system. You would have to log in and run it. It's nothing more than a shopping cart and inventory management system.. These systems are very simple, so not much to it. I can put 2 programs out, one with "Cart" and one out with "Kart". "Kart" will work and "Cart" will fail..
I have it working - so no big deal. Just took me a while to figure out what was going on...
Have a great day.. Dan
|
|
|
Post by meerkat on Dec 18, 2008 19:12:02 GMT -5
OK! Finally isolated the problem. I found my program still errors and it has nothing to do with the variable... Hope someone can show me what I'm doing wrong. I have one program running another. The program that is RUN has the problem... Here is the RUNner: childDir$ = DefaultDir$ + "\projects\a_project\" [top] cls button #runit, "Run Program",[runit] wait [runit]
html "<HR><CENTER>" button #ex, "Exit Runned Program",[top] html "<HR>" prog$ = "a9.bas" run childDir$;prog$,#child render #child wait
Here is the RUNned program. Whenever I try to do anything with EventKey$ it errors. I can print EventKey$ but I cannot get the length of it, or any variable derived from EventKey$ I can get the length of other variables In this example "a = len(a$)" is ok but "x = len(EventKey$)" fails. If I say x$ = EventKey$ and then try and get the len(x$) it will fail.. cls html "<TABLE BORDER=1><TR><TD COLSPAN=2 id=inCart></TD>" html "</TR><TR><TD>Item 10<BR>" itemNum = 10 button #ac, "AddToCart", [doAddCart] #ac setkey(itemNum)
html "</TD><TD>Item 20<BR>" itemNum = 20 button #ac, "AddToCart", [doAddCart] #ac setkey(itemNum) html "</TD></TR></TABLE>" wait [doAddCart] 'print EventKey$ x$ = EventKey$ a$ = "XXX" a = len(a$) x = len(EventKey$) html "<script> document.getElementById('inCart').innerHTML = '" html "Added:";x$ html "';</script>" wait
Thanks for the help..
|
|
|
Post by meerkat on Dec 19, 2008 5:13:33 GMT -5
There is a work around. If you do not "setkey", it works. Just make the handle meaningful so you can use it when you get the EventKey$ For example: itemNum = 10 item.itemNum$ = "#item";itemNum button #item.itemNum$, "AddToCart", [doAddCart]
Then to get the itemNum of the button itemNum$ = mid$(EventKey$,6) itemNum = val(itemNum$)
Thanks for the help...
|
|
|
Post by Carl Gundel - admin on Dec 19, 2008 10:33:57 GMT -5
Glad you found a workaround. I will be investigating this issue today. -Carl There is a work around. If you do not "setkey", it works. Just make the handle meaningful so you can use it when you get the EventKey$ For example: itemNum = 10 item.itemNum$ = "#item";itemNum button #item.itemNum$, "AddToCart", [doAddCart]
Then to get the itemNum of the button itemNum$ = mid$(EventKey$,6) itemNum = val(itemNum$)
Thanks for the help...
|
|
|
Post by Carl Gundel - admin on Dec 19, 2008 12:29:15 GMT -5
Okay, the reason for this is simple. The setkey() method is expecting a string, not a number. So, what we need is a better runtime error and that error should occur when the setkey() method is invoked.
-Carl
|
|
|
Post by meerkat on Dec 19, 2008 17:06:55 GMT -5
Duh!!! I know that. Too many late hours.. I guess I've gotten used to the fact that it always works when not being RUN. for example, this works itemNum = 10 link #ac, "Add_To_Cart", [doAddCart] #ac setkey(itemNum$) wait [doAddCart] a = val(EvemtKey$) print a wait
Thanks Carl
|
|
|
Post by Carl Gundel - admin on Dec 22, 2008 12:16:38 GMT -5
Duh!!! I know that. Too many late hours.. I guess I've gotten used to the fact that it always works when not being RUN. for example, this works itemNum = 10 link #ac, "Add_To_Cart", [doAddCart] #ac setkey(itemNum$) wait [doAddCart] a = val(EvemtKey$) print a wait
You have two different variables in the code above, itemNum and itemNum$ -Carl
|
|
|
Post by meerkat on Dec 22, 2008 13:47:07 GMT -5
Ok! I pulled some code from a working program. Modified it a little. This passes the key as a numeric value.
topicNum = 21 html "topic Num: ";topicNum;"<BR>" button #tvue, "Topic", [topicVue] #tvue setkey(topicNum) wait
[topicVue] viewTopicNum$ = EventKey$ viewTopicNum = val(EventKey$) print print "---------" print viewTopicNum$ print viewTopicNum
wait
I guess I have lots of programs to change if you place an error on the setkey for character values.
|
|
|
Post by StefanPendl on Dec 22, 2008 14:08:28 GMT -5
I guess I have lots of programs to change if you place an error on the setkey for character values. Okay, the reason for this is simple. The setkey() method is expecting a string, not a number. The above tells us, that strings are expected by that function, but numbers are not. The main problem was mixing strings and numbers, this resulted in the ID being always the same.
|
|