search and get value from String - mapping

AM new to altova mapforce.I need to search and get value from String.How to write user defined Function for this?
string is abc|A,cde|B
Input is abc
need output A

You can use libraries , substring-after
Send the string as first argument and '|' as second argument

Related

For each in by reference or value

I have the following code:
dim key
for each key in Request.Querystring
'do something
key = sanitized_param(key)
next
My question for you classic-asp connoisseur, does classic-asp, or asp in general, pass the variables as references(memory), or by value? Trying to figure out if I sanitize the key variable and pass it back to itself, is it just "alive" for that loop, or does the new value get passed to the original QueryString?
Request.QueryString retrieves the query string parameters by value from the page headers.
You can only make changes to a query string once its been retrieved via Request.QueryString, but you can't make changes directly to Request.QueryString as it's read-only (If you could make changes you would presumably use Response.QueryString, but this isn't a valid response command).
I'm guessing you're trying to sanitize all your query strings in one go? This isn't really possible or indeed necessary. You would typically sanitize a query string as and when you request it:
Response.Write(sanitized_param(Request.QueryString("myQS")))
Or to assign the query string to a variable first then sanitize it:
Dim myQS
myQS = Request.QueryString("myQS")
myQS = sanitized_param(myQS)
' or
myQS = sanitized_param(Request.QueryString("myQS"))
Once the query string has been assigned to a variable and sanitized you're able to reference that variable as often as you like without having to pass it to your sanitize function again.
Also, your example code doesn't make much sense. The key value in your for each loop is referencing just the names of your query strings and not their values. If Response.QueryString was a valid ASP command you would do:
Response.QueryString(key) = sanitized_param(Request.QueryString(key))
But again, this isn't possible.
EDIT: This solution might be what you're looking for:
Create a dictionary object, call it "QueryString" for example. Loop through all your query strings and add a sanitized version to the dictionary object.
Dim QueryString : Set QueryString = Server.CreateObject("Scripting.Dictionary")
For Each Item In Request.QueryString
QueryString.Add Item,sanitized_param(Request.QueryString(Item))
next
Now, to retrieve a sanitized version of a query string just use:
QueryString.Item("query_string_name")
Or for the original unsanitized version you could still use:
Request.QueryString("query_string_name")
Just like Request.QueryString, the dictionary object is forgiving and won't return an error if you ask for a query string that doesn't exist.
You could also create a function for retrieving sanitized query strings, for example:
Function SanitizedQS(ByVal qsName)
SanitizedQS = sanitized_param(Request.QueryString(qsName))
End Function
And rather than using Request.QueryString("query_string_name") just use SanitizedQS("query_string_name").

Convert from Set to List in Dart / Flutter?

I have a Set of type Set<WordPair> & I want to convert it to List of type List<String> because I want to save it using SharedPreferences API in Flutter
Currently, my state looks like
final Set<WordPair> _saved = Set<WordPair>();
Now I want to save the _saved variable into SharedPreferences
If I do, prefs.setStringList('saved', _saved.toList()); it gives me compilation error like
[dart] The argument type 'Set' can't be assigned to the parameter type 'List'. [argument_type_not_assignable]
How do I store complete _saved variable in SharedPreferences?
The reason you are unable to save it in the Preferences even after converting it into a list is that you are trying to save StringList (prefs.setStringList) whereas your set is of type WordPair
A workaround for that could be,
prefs.setStringList('saved', _saved.map((WordPair wordPairItem) => wordPairItem.toString()).toList());
i.e converting each item into String and then save it as StringList
To your follow-up question in the comments:
how do I convert from List<String> to Set<WordPair> in initState? As there is no .toWordPair() & wrapping up takes 2 args so Idk how to do it?
As per documentation, WordPair is Representation of a combination of 2 words, first and second. Therefore, you can break the String into two substrings and pass those 2 substrings in the respective argument positions.
[Update] (solution proposed by the Author of the follow-up question)
The solution can be found at here

Google Spreadsheet CHECKSTRING(url ; string) (new function needed)

I’m really new to programming so first of all I beg your pardon for my my questions.
I would like to create a function to search the webpage of a site in order to find any string is present.
This function could be written like this. Thanks in advance for your precious help. Then How I can activate it to use it in a cell.
Thanks for your precious help.
Seb
--
CHECKSTRING(url ; string)
• url - The URL of the web page to examine, including protocol (e.g. http:// or https://).
The value for url must either be enclosed in quotation marks or be a reference to a cell containing the appropriate text.
• String – The STRING to find in the page source from the URL. The value for String must either be enclosed in quotation marks or be a reference to a cell containing the appropriate text.
This function returns the line number position at which the STRING is first found within URL code source, case-sensitive.
This function returns -1 or FASE when the check answer is negative.
Did you try the FINDfunction ?
=iferror(find(string_to_search, url), false)
or, depending on your locale:
=iferror(find(string_to_search; url); false)
where string or URL can be passed in as string, or as cell references.
NOTE: if you want to do a case-insensitve search, replace the FIND() with SEARCH()

MVC Database to list with id reference

I'm writing an MVC application and want to query my database with a search parameter and put all of the results into a list. Right now my code to try this looks like:
Character character = db.Characters.ToList().Find(User.Identity.GetUserId());
Which is throwing up a error. Is there a way I can do this? Break it down into two statements for example? I tried
Character character = db.Characters.Find(User.Identity.GetUserId());
character = character.ToList();
but that isn't working either.
When using the extension method Find() you must be sure that in your model you have the attribute [Key] in the property representing your Id (primary key in your table).
And you can try like this:
Character character = db.Characters.Find(User.Identity.GetUserId());
The line above will work but not this one character= character.ToList(); because you declare character as an object and you can't assign it to a list of object in your case Character
If you want it to work, you can do something like this:
var myCharacters =db.Characters.Where(c=>c.someField=="someValue");
List<Character> myList = myCharacters.ToList();
Hope it will help.

Replace a string with another in request.rawurl not working

I want to replace some string in my url like this
request.RawUrl.ToString().Replace("sometext566666", "othertest")
but it s not working why is it so?
For example, the original url is like
/sometext4554544454.aspx
and I want it like this
/sometext.aspx
I'm guessing that this is .NET. If so, you should be aware the String.Replace() returns a new string containing the result of the replacement (as do all other methods that purport to modify a string).
So you need to assign the result to a variable or field to hold the result. In some circumstances, you might assign the result back to the same place you obtained the original string from. But you're not allowed to overwrite RawUrl (and, it would be potentially confusing for you to do so).
The statement you are using is working, but you are not assigning the result of the replace function, just executing it.
request.RawUrl.ToString().Replace("sometext566666", "othertest")
If you want to keep the result, you will need to assign it to a string.
e.g.
String result = request.RawUrl.ToString().Replace("sometext566666", "othertest");
Otherwise, you can assign it to the same RawURL but I think that is a URI so you'll need to use a new URI, something like:
request.RawUrl = new URI(request.RawUrl.ToString().Replace("sometext566666", "othertest"));
Nevertheless, I'm not sure if you can actually edit that property.

Resources