How to clear the cache
Alex Tweedly
alex at tweedly.net
Sun May 19 18:52:19 EDT 2013
Shawn,
you have a couple of issues here ...
1. (minor)
if this is the entire script, then tCount is a local (i.e. handler
local) variable, so it is re-created each time the handler is called, so
you finish up with the same value each time. I think you ant to make it
a script-local variable (i.e. declare it outside any handler) and then
it retains its value from one call to the next. (I'm also paranoid, so I
added a check for it not being a number). And since it's a script-local,
I renamed it to sCount :-)
2. in line 3, you have an extra keyword "URL" You have
*put* URL ("www.google.com?count=" & tCount) into pURL
and you need to simply have
*put* ("www.google.com?count=" & tCount) into pURL
We are just trying to build up the string of the URL - what you had was
trying to fetch it.
3. (trivial) I renamed pURL to tURL just to follow convention - it's a
local variable, not a parameter :-)
I changed those - and a couple of other things for my testing, and got
the following script which seems to work OK; fails with "invalid host
address" when wifi is switched off.
local sCount
on mouseUp
if sCount is not a number then
put 1 into sCount
else
add 1 to sCount
end if
put ("http://www.google.com/?count=" & sCount) into tURL
put the millisecs && tURL &CR& the Result &CR&CR after field "F" --
just for testing
get URL tURL
if the result is empty then
put the millisecs &&"success" &CR after field "F"
else
put the millisecs && the result &CR after field "F"
end if
end mouseUp
-- Alex.
On 19/05/2013 17:56, Shawn Blc wrote:
> Alex,
>
> I added your idea of varying the URL each time, but still not able to get
> the script to work correctly. See below.
>
> For instance, on my mac, when I disable wifi I shouldn't be able to
> connect, when I enable my wifi I should be able to connect.
>
> What's wrong with my script?
>
>
> *on* mouseUp
>
> *add* 1 to tCount
>
> *put* URL ("www.google.com?count=" & tCount) into pURL
>
> *get* URL pURL
>
> *put* the result into tResult
>
> *if* tResult is not empty *then*
>
> *put* "disconnected" && tResult into field "fldStatus"
>
> *show* image "imageRed"
>
> *hide* image "imageGreen"
>
> *return* false
>
> *else*
>
> *put* "connected" into field "fldStatus"
>
> *show* image "imageGreen"
>
> *hide* image "imageRed"
>
> *end* *if*
>
> *end* mouseUp
>
>
> On Sun, May 19, 2013 at 9:06 AM, Alex Tweedly <alex at tweedly.net> wrote:
>
>> unload URL tURL
>>
>> or if you prefer make the URL vary each time
>>
>> add 1 to tCount
>> put ("http://mydomain.com/**theurlname.lc?count=<http://mydomain.com/theurlname.lc?count=>"
>> & tCount) into tURL
>> and use that URL.
>>
>> -- Alex.
>>
>>
>>
>> On 19/05/2013 12:59, Shawn Blc wrote:
>>
>>> I have a little script to check for an internet connection. Problem is
>>> that if I take this little script out of the preOpenCard and put it into a
>>> button the results are the same. It keeps the last state, regardless if I
>>> disconnect my wifi or not. I'm thinking that the URL that I'm connecting
>>> to to check for an internet connection is still in cache.
>>>
>>> How would I clear this cache? These don't work.
>>> clear URL
>>> clear cache
>>>
>>> Any help is appreciated or at least point me in the right direction.
>>>
>>> Dank.
>>> ______________________________**_________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>>
>>
>> ______________________________**_________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list