Dynamically create String variables

Discussions about Coding and Scripting
User avatar
PrinceOfFunky
Godlike
Posts: 1160
Joined: Mon Aug 31, 2015 10:31 pm

Dynamically create String variables

Post by PrinceOfFunky » Sun Dec 10, 2017 9:22 am

I was looking through all the native function declarations in the UT packages and I found interesting stuff in WebRequest.uc:

Code: Select all

native final function AddVariable(string VariableName, string Value);
native final function string GetVariable(string VariableName, optional string DefaultValue);
native final function int GetVariableCount(string VariableName);
native final function string GetVariableNumber(string VariableName, int Number, optional string DefaultValue);
Does it mean we could dynamically create String variables like with a dynamic array?

Also, this variable is another interesting thing:

Code: Select all

var private native const int VariableMap[5];	// TMultiMap<FString, FString>!
I wonder if this map could be set by SetPropertyText().

And this is what I found in WebResponse.uc:

Code: Select all

native final function IncludeBinaryFile(string Filename);
Does it mean we can send binary files to those who access our UT built webpage?
"Your stuff is known to be buggy and unfinished/not properly tested"

User avatar
Barbie
Godlike
Posts: 2107
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Dynamically create String variables

Post by Barbie » Sun Dec 10, 2017 12:24 pm

PrinceOfFunky wrote:Does it mean we could dynamically create String variables like with a dynamic array?
From a first and quick view: no. I guess that these functions manage ampersand-separated name/value-pairs (aka "associative array") that are used in a URL for example:

Code: Select all

http://23.45.67.89/page.html?name1=value1&name2=value2
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Dynamically create String variables

Post by nogardilaref » Sun Dec 10, 2017 1:20 pm

What Barbie said. ^
Everything there represents an HTTP request and nothing more.

As a matter of fact, as it is, the HTTP support is extremely primitive with those classes however, but fortunately the engine gives you full control of what you send and receive so you can essentially create your own HTTP request class pretty much from scratch, and theoretically even support for SSL and HTTP/2 would be possible, although it wouldn't probably compensate the effort.
PrinceOfFunky wrote: And this is what I found in WebResponse.uc:

Code: Select all

native final function IncludeBinaryFile(string Filename);
Does it mean we can send binary files to those who access our UT built webpage?
Yes, that's mostly meant for things like images though, like returning a JPG or PNG as part of your web interface, but you can return anything really.

User avatar
PrinceOfFunky
Godlike
Posts: 1160
Joined: Mon Aug 31, 2015 10:31 pm

Re: Dynamically create String variables

Post by PrinceOfFunky » Sun Dec 10, 2017 5:19 pm

I know it's for the HTTP query string options, but it's still an AddVariable() and GetVariable(), so I guess it can be used to store an arbitrary amount of string variables, no?
"Your stuff is known to be buggy and unfinished/not properly tested"

Higor
Godlike
Posts: 1832
Joined: Sun Mar 04, 2012 6:47 pm

Re: Dynamically create String variables

Post by Higor » Sun Dec 10, 2017 5:29 pm

UnTemplate.h > TMap
That's what it is, all you're seeing is a halfassed unrealscript implementation.
ImageImage
Image unreal://23.111.157.138:7777
Image unreal://46.228.199.205:7788