dim agent as string

Ok, this is not tested, and I could typed something wrong:

Dim theRand as New Random // Instantiate a randomizer object

Dim theString(2) As String  // Array

theString(0) = “String #1”
theString(1) = “String #2”
theString(2) = “String #3”

Dim myRandomString As String = theString(theRand.InRange(0,2))  // Here is a random string

Read this: http://documentation.xojo.com/index.php/Dim
and this: http://documentation.xojo.com/index.php/Random
and this: http://documentation.xojo.com/index.php/Array

Study and adjust your program as necessary after understanding the concepts.

Then reread all PDFs again with calm.
You are lacking of very basic concepts, so you are not doing your homework as you should.

No, it can’t. And unless you understand why you will not make any progress.

I rephrase my question:

If you say: “I go to Italy”. Later you say “I go to France.”. Even later you say “I go to Norway.”

Where do I think you will go to now?

If you don’t want to think about the question and the why then I’m wasting my time trying to help you.

And if you don’t want to put in the effort to learn the basics and read the introduction to programming, then the problem is not my tone but your attitude.

[quote=90769:@Markus Winter]
If you don’t want to think about the question and the why then I’m wasting my time trying to help you.
And if you don’t want to put in the effort to learn the basics and read the introduction to programming, then the problem is not my tone but your attitude.[/quote]

Oh good… it isn’t just me… :slight_smile:

Well, Germans are very direct :wink:

Dja vu : Just remembered the super kung fu master mercenary special agent and programmer from other day. :stuck_out_tongue:

:slight_smile:

[quote=90765:@Dave S]And you obviously did NOT read any of the documentation…
If you had I would have seen an ARRAY in your code, I would have seen the word SHUFFLE in your code…

DIM Agent () as string
dim i as integer
agent.append "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101  Firefox/28.0"
agent.append  "Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0"
agent.append "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
agent.append "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"
agent.append "Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36"
agent.append "Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"
agent.append "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
agent.append  "Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52"
agent.append "Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00"
agent.append  "Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7"
agent.append "Windows; U; Windows NT 6.1; x64; fr; rv:1.9.2.13) Gecko/20101203 Firebird/3.6.13"

for i=1 to 5
agent.shuffle
select case i
case 1
HTMLViewer1.UserAgent = agent(0)
case 2
HTMLViewer2.UserAgent = agent(0)
case 3
HTMLViewer3.UserAgent = agent(0)
case 4
HTMLViewer4.UserAgent = agent(0)
case 5
HTMLViewer5.UserAgent = agent (0)
end select
next i

I am not saying this “works”, as I typed it off the top of my head… but unless you make an attempt to figure things out, you will not get much further support. Just typing code and saying “it doesn’t work” won’t cut it. You need to make an attempt to figure out why… how else are you going to learn…[/quote]

I typed that and nothing happens it start debugging but not open my app :frowning:

[quote=90768:@Rick Araujo]Ok, this is not tested, and I could typed something wrong:

Dim theRand as New Random // Instantiate a randomizer object

Dim theString(2) As String  // Array

theString(0) = “String #1”
theString(1) = “String #2”
theString(2) = “String #3”

Dim myRandomString As String = theString(theRand.InRange(0,2))  // Here is a random string

Read this: http://documentation.xojo.com/index.php/Dim
and this: http://documentation.xojo.com/index.php/Random
and this: http://documentation.xojo.com/index.php/Array

Study and adjust your program as necessary after understanding the concepts.

Then reread all PDFs again with calm.
You are lacking of very basic concepts, so you are not doing your homework as you should.[/quote]
SO “String #3” i should add the useragent like that?
thanks

Your code is bad, it doesnt even take Violet color for agent between “” thanks anyways, i see no on explain to i can understand.

His code is good, your willingness to learn is zero.

The important lines were:

[quote]Then reread all PDFs again with calm.
You are lacking of very basic concepts, so you are not doing your homework as you should.[/quote]

Still no answer to my very simple question.

I think I go away now and cry a bit …

Yup… I give up too… .He is unable/willing to read the documentation… he is unable/willing to attempt to do things for himself. He IGNORED the fact that I said my code was only an off the cuff example… not a working solution, then cries when it did not work .

So I too think I will go away… but I shall not cry… there is nothing worth crying about

Tosha… good luck in your endeavors… feel free to ask more question once you can demonstrate you have done a little homework and excerted some effort to solve problems for your self

[Geez… I hope we are not beginning to sound like Stack-Overflow here]

[quote=90765:@Dave S]And you obviously did NOT read any of the documentation…
If you had I would have seen an ARRAY in your code, I would have seen the word SHUFFLE in your code…

DIM Agent () as string
dim i as integer
agent.append "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101  Firefox/28.0"
agent.append  "Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0"
agent.append "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
agent.append "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"
agent.append "Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36"
agent.append "Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"
agent.append "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
agent.append  "Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52"
agent.append "Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00"
agent.append  "Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031026 Firebird/0.7"
agent.append "Windows; U; Windows NT 6.1; x64; fr; rv:1.9.2.13) Gecko/20101203 Firebird/3.6.13"

for i=1 to 5
agent.shuffle
select case i
case 1
HTMLViewer1.UserAgent = agent(0)
case 2
HTMLViewer2.UserAgent = agent(0)
case 3
HTMLViewer3.UserAgent = agent(0)
case 4
HTMLViewer4.UserAgent = agent(0)
case 5
HTMLViewer5.UserAgent = agent (0)
end select
next i

I am not saying this “works”, as I typed it off the top of my head… but unless you make an attempt to figure things out, you will not get much further support. Just typing code and saying “it doesn’t work” won’t cut it. You need to make an attempt to figure out why… how else are you going to learn…[/quote]

YEEEESSSS IT WORKS heheheh :stuck_out_tongue:
Just onequestion, what if i want 300 useragents Rotate only in 5 htmlviewers?
Shoud i only add "Agent.Append “useragent21”
"Agent.Append “useragent2”
and so on…
and thjen only add Case 6, Case 7 and so on…?
Will it rotate on each Refresh from all cases one by one? OR it will be still same one case till 5?
Thanks So much Sir :slight_smile:

Please post questions in the public forum… not in private messages

ok sorry :)$

so again here:
I found 2500 useragents from one text file in google. Is there a way to ratehr then type this in code manually, add some prefix to coide and load it from folder of app location?
So i will just enter the path of loacation (MAcOsX and Windows) and once it will be loading random useragents it load that text file and use it?
I will really not disturb you anymore as it only you asked me very nice.
thank you mister very kindly

[quote=90799:@Tosha Teeple]ok sorry :)$

so again here:
I found 2500 useragents from one text file in google. Is there a way to ratehr then type this in code manually, add some prefix to coide and load it from folder of app location?
So i will just enter the path of loacation (MAcOsX and Windows) and once it will be loading random useragents it load that text file and use it?
I will really not disturb you anymore as it only you asked me very nice.
thank you mister very kindly[/quote]

Here are some key points.

First, to get the contents of a text file, you’ll need to get a FolderItem for the file (probably using an OpenDialog), then open it with a TextInputStream.

Then you will be creating an array of the lines. You can do this with repeated ReadLine commands, or one big ReadAll and a Split on EndOfLine.

Also remember, if you want to keep the array around for multiple uses, either make it Static (for use in that method only), or a Property (to use it in more than one place).

well thx for answer but i still not get this point so …:frowning: anyway i delted all not needed useragents and i get only 230 bout so i can type it :slight_smile: thanks anyways.

No i was thinking just it only detect from location, not need to load with folder item manually, i mean if i check the checkbox it will located useragent linst.txt from computer, and not need to me in code, i saw one app like this already so just can not figure out how to d oit, thx

First, in Stack Overflow, chances are his question would have been locked for not being precise enough.

Second, you showed far more patience than I would. There is a pattern to this :

  • guy posts question with ill built code showing clearly he did not even try to read the documentation
  • title is as elusive as possible, and guy gives as little details as he can about what he wants to achieve
  • guy asks for members to write the corrected code
  • when told how to solve the defects guy explains he is not knowledgeable and requests again code to be written for him
  • when some explain that he should do his homework, guy gets offended that others are not nice and cruel to newbies
  • guy then shows more and more ambition without showing any willingness to learn (from 5 to 2500 agents).
  • guy tries to take advantage of perceived mentors by private messages
  • guy keeps whining that he is a newbie and should be cared for
  • guy gets angry when reminded to read the LR and demands code to be written for him

The worst case of such verifiable pattern will always remain https://forum.xojo.com/11171-htmlviewer-loadurl

Have you heard of the cuckoo bird offsprings taking advantage of other birds feed ?

If it walks like a cuckoo bird, if it screams like a cuckoo bird …

Why do I keep seeing the acronym RTFM?

why you answer on my post like this? i didnt asked on this loadurl of htmlviewer, next people from Stack-Overflow are more nice then people from here I think, it’s a big shame you make a nice pub for XOJO soft company, I will write a nice article in my joomla blog with 2000 readers each day, and i make a screen also of you and your photo sir, because people like you who has been written as PRO on this site can not answer to new members like this.
Next, also it shows how inteligent you are, so what you are trying to do on my posts anyway?