Auto click link every 30 mins and repeat

User avatar
DocAElstein
4StarLounger
Posts: 584
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Auto click link every 30 mins and repeat

Post by DocAElstein »

OK, thx, I think I am getting it. I need to engrave this somewhere. … placeholder … name of the box waiting to have something put in it .. definition of what it is ….

I think I was half way there already at thinking I was talking rubbish in my last post, at least the bit about … do the thing with Parameters
What you said … .OnTime (and .Run) actually evaluate the argument(s) and then pass those evaluated copies ByVal to the subroutine …. is the point.
Or rather, in my case, I could not, and was not even trying to, or anything similar to, passing anything other than values. I was and still am actually just giving values all the time. Either of the two Application.OnTime code lines in this do exactly the same thing

Code: Select all

 Public Sub SchedualIt()
Dim Nmbr As Long, Wrd As String
 Let Nmbr = 25: Let Wrd = "A Word Argument"
 Application.OnTime Now + TimeValue("00:00:02"), "'DoMeLater      " & Nmbr & "  ,   """ & Wrd & """        '"
 Application.OnTime Now + TimeValue("00:00:04"), "'DoMeLater      25  ,   ""A Word Argument""        '"
End Sub
Public Sub DoMeLater(ByVal ANumber As Long, ByVal AWord As String)
Debug.Print ANumber & "   " & AWord
End Sub
In that example, either of these strings

Code: Select all

 "'DoMeLater      " & Nmbr & "  ,   """ & Wrd & """        '"
"'DoMeLater      25  ,   ""A Word Argument""        '" 

, will be giving this same thing as what will be used later which is these values

Code: Select all

 'DoMeLater      25  ,   "A Word Argument"        '
So all I did with the bit of " & Nmbr & " , """ & Wrd & """ was show a way to not have to hard code the line, that’s all. Not necessarily an unuseful thing, but not passing something which I thought could be filled later or rather in the meantime , before the scheduled thing started later. That would need to be done in a global variable or cell value , for example, something like you did originally

_.______

( I note that in the syntax of Application.Run the named arguments are like Arg1:=, Arg2:= etc.. So I think the choice of the word Arg there ties up with our definitions. )

_._____

I see the limitation now of what can be done, and can understand the reluctance to say we are passing arguments with On-Time. We are doing something similar. It is not clear if we have access to the full Application.Run possibilities but we are limited by the syntax of On-Time at any rate to giving a string. The first thing in the string is taken as a name, the macro name. The other stuff is taken as if it was a text literal value, and that can somehow be taken by the named macro as if it was passed text value. (And I think it is always a string, a literal string value. In that last example , this would do the same, ( passing the string 25 instead of the number 25 )

Code: Select all

 Application.OnTime Now + TimeValue("00:00:04"), "'DoMeLater      ""25""  ,   ""A Word Argument""        '"
End Sub
Public Sub DoMeLater(ByVal ANumber As Long, ByVal AWord As String)
Debug.Print ANumber & "   " & AWord
End Sub
Its OK for my Later doing sub to have that ANumber As Long . I think it will take the string and as long as it looks like a Long number its happy - that is the usual VBA conveniently tolerating / wired to check and convert stuff, whereby strings looking like numbers are usually happily used as the number it looks like, when a number is expected in the thing it was given to.


It remains a bit of a puzzle what is actually going on. Maybe Microsoft were confused themselves at the time, and could not quite figure out what they had or had not done when they made the On-Time thing.


I may not quite be fully there yet, but thanks for knocking me back on track when I totally veer off in the wrong direction.
I still think this phenomena that I called "passing arguments using On-Time" is something I think is useful, will use, and probably tell other people about if I think it could be useful to them. But I have now learnt that it is not quite as useful as I was probably thinking, as its more limited than I probably realised.
But I am slightly put off now, following our discusions, to say we can pass arguments with On-Time, as I did oroginally, since it seems we can’t, not fully.
But I can’t think of what else it could be if it isn’t passing arguments using On-Time
I wonder if they intended to make On-Time take arguments just as Application.Run does. Maybe at some point they thought they did. But it was broken: The arguments always got evaluated as if they were strings, and taken as string values.

_._______

It’s a bit of a Bummer not being able to pass objects and arrays. I had not noticed, or thought about it actually, but of course its obvious now I know everything a little better. I have not often wanted to pass objects. Arrays I do like to pass sometimes, but mostly just values arrays. So I can think of some pretty workarounds involving nice conversions of structured strings efficiently into arrays, so passing strings gets me personally quite a long way, and I like doing it: Chris Greaves told me that computers are just strings, so manipulating them into 2 dimensional arrays feels nice. After all, I guess Excel is just someone else’s pretty interface for showing your strings manipulated into 2 dimension.

_.____________

Edit , I just discovered a neat new phenomena - hit the re-fresh and a Union Jack flag appears on your Avatar. :)
:uk: :uk: :england: :germany: :uk: :uk: https://i.postimg.cc/ZRG4FKWF/Speak-Eas ... riotic.jpg
.... maybe that will help me figure out a hack to get my Live Cams wired into my Avatar..some sort of rapid auto click combined with rapid auto uploading of the next frame...
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(