Thread

Passing a Variable to a url (Sdk)

Passing a Variable to a url // Sdk

1  |  

scifair

Aug 3, 2001, 4:27pm
Does anyone know of a simple way for me to send a variable to a web browser
when pulling up a url from a bot? For example aw_url_send just lets me put
in the url, but I need to be able to send a variable (such as to an ASP
page) so that a slightly different page could be opened depending on the
variable. This is for a bot that I am writing in c++ if that makes any
difference.
Thanks in advance,
Bogey

faber

Aug 4, 2001, 7:22am
Well, if your ASP page understand the "GET" method you can just add those variables to the url

www.somehost.somedomain/somepage.asp?somevariable=somevalue

Faber


"scifair" <bkondracki at hotmail.com> schrieb im Newsbeitrag news:3b6aed13$1 at server1.Activeworlds.com...
> Does anyone know of a simple way for me to send a variable to a web browser
> when pulling up a url from a bot? For example aw_url_send just lets me put
> in the url, but I need to be able to send a variable (such as to an ASP
> page) so that a slightly different page could be opened depending on the
> variable. This is for a bot that I am writing in c++ if that makes any
> difference.
> Thanks in advance,
> Bogey
>
>
>
>

gamer

Aug 4, 2001, 7:41pm
I think he wants to get the url form the page....therefore woul;dnt want to
specify it in the URL, becuase in theory, he wouldnt know what the variable
is yet...if you catch my drift.

[View Quote]

gamer

Aug 4, 2001, 7:41pm
> I think he wants to get the url form the page....therefore
eck "I think he want to get the cariable from...."

gamer

Aug 4, 2001, 7:42pm
> eck "I think he want to get the cariable from...."
ECK! *variable

scifair

Aug 8, 2001, 4:06pm
> I think he wants to get the url form the page....therefore woul;dnt want
to
> specify it in the URL, becuase in theory, he wouldnt know what the
variable
> is yet...if you catch my drift.

yeh i think that kind of catches what i meant, so i don't think the
following would work:


since i would use the following to send the url and it would look like:
aw_url_send(someuser,
"www.somehost.somedomain/somepage.asp?somevariable=somevalue", NULL);
I would still have to add a new aw_url_send for each value of somevalue
since it wouldn't interpret it as a variable but just as an int or a string
or whatever it is. Does anyone know of anyway to get around this??

Thanks,
Bogey

grimble

Aug 8, 2001, 10:42pm
Is anyone following this thread, because its confusing the hell out of me!!

If you are sending the URL from bot then the bot needs to understand the
variables. Build the staring in the bot code and the use aw_url_send.

If the URL is linked from another page, then where does the bot fit in?

If you are looking for hidden/visible form values are preset in a web-page,
use a combination of a variable (as faber suggested) as the trigger for the
ASP to prefill the values.

Am I missing the point here?

Grims.

[View Quote]

jerme

Aug 8, 2001, 11:13pm
I'm with Grimble, as this is really confusing. However, I'm going to do my
best to clarify what I think is the answer to your question.....

The question was rather confusing sounding, but the example was clearer...so
I'll use it.

>For example aw_url_send just lets me put
>in the url, but I need to be able to send a variable (such as to an ASP
>page) so that a slightly different page could be opened depending on the
>variable.

If I understand correctly... You want the bot to send a URL to the client,
along with a variable. The variable will determine which page will be
displayed, or can just fill in certain parts.

This could be done with CGI or ASP (just as faber suggested). Your bot
would send the url to the client, the url would point to the script. (I
would use CGI/PERL) The script would parse the input, and output a page, or
replace items in a template with inputted values.
I have all the parts to the script, and I could put one together for you
relatively quickly.

If I'm totally off, let me know... But I think that clarifies what Faber was
saying...

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Booker
JTech Web Systems
(www.JTechWebSystems.com -- Coming Soon)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[View Quote]

scifair

Aug 9, 2001, 1:35pm
> If I understand correctly... You want the bot to send a URL to the client,
> along with a variable. The variable will determine which page will be
> displayed, or can just fill in certain parts.

That's exactly what I want to do. Grimble aqnd faber suggested good
solutions to my original post being that since I am sending the URL from the
bot, I should build the string in the bot code and then use aw_url_send.
The problem is I forgot to mention that in my bot there are 440 different
variable values so to do it that way I would have to use 440 different
aw_url_send's. If somehow I could get aw_url_send to recognize that what I
was sending was a variable holding an integer value as opposed to just a
string I could do it with just one aw_url_send.

[View Quote] I haven't done anything in CGI or PERL so I'm not exactly sure how they
work. I think that I run into the same problem that I did above though. If
im looking at that wrong or if anyone can think of a way to get around it
I'd appreciate. Thanks for your help so far and sorry if I've been a little
confusing .
Bogey

grimble

Aug 9, 2001, 4:28pm
I still don't see the problem. One aw_url_send preceeded by a bit of string
building.

In MSVC++ its something like this - I only typed it directly into OE cuz I
don't have time right now to try it out, but you should get the drift ...

int SendParmURL(int urlSession, CString urlParm)
{
CStirng targetURL;


targetURL.Format("www.somehost.somedomain/somepage.asp?somevariable=%s",
urlParm);
return aw_url_send(urlSession, targetURL, NULL);
}

Then just pass the target session and the string parm to the function
SendParmURL.

SendParmURL(avatarSession, "Grimble")

For integer values, urlParm is an int and use %d instead of %s in the Format
expression.

etc., etc., etc.

Is this what you need to do?

Grims



[View Quote]

jerme

Aug 9, 2001, 11:54pm
> The problem is I forgot to mention that in my bot there are 440 different
> variable values so to do it that way I would have to use 440 different
> aw_url_send's

You would have to use one *huge* url send... in the format...
http://www.yoursite.com/somescript.cgi?var1=data1&var2=data2&var3=data3

<path to script><script name>? [key1] = [value1] & [key2] = [value2]

As you can see, it takes the use of many name/value pairs...
The script can split this long URL into intelligible chunks, and test the
values to take the proper course of action....

There may actually be a limit to how much information you can pass. You
could consider writing the information to a file, and having the script
retrieve it to display the page. This is a lot more complex a task
though....

I would work with you to write this script.... e-mail or telegram me if
you're interested.... (I couldn't start immediately, I'm still working on
the new AW Webring script....)

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Booker
JTech Web Systems
(www.JTechWebSystems.com -- Coming Soon)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[View Quote]

grimble

Aug 10, 2001, 12:46pm
OK ... PLEASE clear this up for me.

Are there 440 different variables VALUES (citnum=1, citnum=2 or citnum=3,
etc.) or 440 different VARIABLES
(citnum=1&citname="AWUser"&avX=-2436&avY=4657?... etc.)? I can't imagine
that there are 440 different peices of information that you would want to
pass to a CGI or ASP script to generate a single page (ARE there over 400 AW
attributes?). If there you do need to pass this amount of information
(yikes), I can see two other options over and above the file option JerMe
suggested.:

(a) Get the web script to do something a bit more interesting - having a set
of URLs that define a conversation between the bot itself and the web-server
via CGI/ASP scripts before sending the url with some generated key to allow
the script to retrieve the information. Much more fun to do and you can do
some HTTP/HTML decoding stuff too in your bot.

(b) Pack the data into a smaller number of large variable values, delimited
by some innocuous character that won't be in any of the values (i.e. "~").

I'm not too keen on using files for temporary storage in asynchronous
environments because of the timing involved. If the url is triggered by an
avatar event (clicking, entering an area or world, etc.), there is every
possibility that the avatar could do it again and again and again in quick
succession. Also, there could be 10 people all there doing the same thing
and you're going to get a very confused script. Calls to ASP scripts are
session-based so its a one-request-one-response conversation unless you
either build some persistence on the web side (servlets, etc.) or make some
conversation model.

If you only want to pass one of the variables in any one call, the string
building routines can handle that in the same way in the same way as the
values. All this is pointless though if you just have 440 different values
to the same variable.

Grims



[View Quote]

ima genius

Aug 10, 2001, 5:51pm
Hi,
Don't forget that when using CString in an variable argument list, you
have to explicitly cast it to LPCTSTR. For example:
targetURL.Format("www.somehost.somedomain/somepage.asp?somevariable=%s",
(LPCTSTR) urlParm);

- Ima

[View Quote]

grimble

Aug 10, 2001, 6:31pm
You only need to do that if its a buffer for returning a value from the
call - such as in GetPrivaterofileString ... CString has a cast for it if
its one-way.

What should be pointed out, however, is that CString is an MFC class and may
not be port to other C++ compilers.

Grims.

[View Quote]

ima genius

Aug 10, 2001, 6:59pm
Hi,
I checked the docs to be sure, and they say:

CString::Format
When you pass a character string as an optional argument, you must cast it
explicitly as LPCTSTR.


CString::operator LPCTSTR
// If the prototype of a function is known to the compiler,
// the LPCTSTR cast operator may be invoked implicitly
lstrcpy(sz, strSports);

// If the prototype isn't known, or is a va_arg prototype,
// you must invoke the cast operator explicitly. For example,
// the va_arg part of a call to sprintf() needs the cast:

sprintf(sz, "I think that %s!\n", (LPCTSTR) strSports);


- Ima :)

[View Quote]

ananas

Aug 10, 2001, 8:22pm
Never did that, always worked without. Sometimes it helps to read the
manual only if needed ;)

[View Quote] --
"_
|
/\
\ /
__/ /_

jerme

Aug 11, 2001, 1:47am
<reply is inline below>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Booker
JTech Web Systems
(www.JTechWebSystems.com -- Coming Soon)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[View Quote] I was wondering that myself... 440 variables would be a nightmare to try to
send in a url....

> (citnum=1&citname="AWUser"&avX=-2436&avY=4657?... etc.)? I can't imagine
> that there are 440 different peices of information that you would want to
> pass to a CGI or ASP script to generate a single page (ARE there over 400
AW
> attributes?). If there you do need to pass this amount of information
> (yikes), I can see two other options over and above the file option JerMe
> suggested.:
>
> (a) Get the web script to do something a bit more interesting - having a
set
> of URLs that define a conversation between the bot itself and the
web-server
> via CGI/ASP scripts before sending the url with some generated key to
allow
> the script to retrieve the information. Much more fun to do and you can do
> some HTTP/HTML decoding stuff too in your bot.
>
> (b) Pack the data into a smaller number of large variable values,
delimited
> by some innocuous character that won't be in any of the values (i.e. "~").
>
> I'm not too keen on using files for temporary storage in asynchronous
> environments because of the timing involved. If the url is triggered by an
> avatar event (clicking, entering an area or world, etc.), there is every
> possibility that the avatar could do it again and again and again in quick
> succession. Also, there could be 10 people all there doing the same thing
> and you're going to get a very confused script.

This problem is very simple to solve. You couldn't have 2 scripts trying to
read and write to the same file, at the same time.... That would produce
hellish results.

Use a random number, or an icriminted index #, as the file name. This
prevents the script from corrupting its self. However, there is still a
rare chance that you could (with precise timeing and a lot of luck) get the
same random # or an index # that hasn't been incrimented. To deal with this
I use (in perl at least..) file locks ( flock() ) to prevent any other
instenation of the script from using the file....You can check for a file
lock. If it's locked, there's a problem.. You can either deal with it by
trying a different file name, or by simply exiting with an error message and
letting the user retry the script.


>Calls to ASP scripts are
> session-based so its a one-request-one-response conversation unless you
> either build some persistence on the web side (servlets, etc.) or make
some
> conversation model.
>
> If you only want to pass one of the variables in any one call, the string
> building routines can handle that in the same way in the same way as the
> values. All this is pointless though if you just have 440 different values
> to the same variable.
>
> Grims
>
>
>
[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2022. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn