Regarding Extract Function - mumps

i have query related to extract function, will Extract Function accept ASCII Value?

The $EXTRACT function when given a string of ASCII characters, will return a substring of that string.
for example $EXTRACT("Hello World",1,6) is "Hello"
If you want to extract the ASCII value of a character in a string, use the function $ASCII.
If you want to create a string given the ASCII values, use the function $CHAR.
For example $EXTRACT("ABC",2) is "B" and $ASCII("ABC",2) is the number 66
and the function $CHAR(67,65,66) is the string "CAB".

Related

a json.getString() function returns a String of strange format so that It can't be compared to string of seemingly same value

When comparing the output of json.getString() to a string of same value i manually inputted into a json file, it's a false comparison.
println("-");
println(jsonScene.getString("value"));
println(jsonScene.getString("value") == "-");
Outputs
-
-
false
The same value is printed but when compared, it's false but should be true.
Remember in Processing (Java) you need to compare Strings using equals():
Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the same and false if they are not.
For example:
println(jsonScene.getString("value").equals("-"));
Check the .charCodeAt(0) for both strings
.trim() both of them before the comparison
Check that typeof jsonScene.getString("value") === "string" (it could be an object with custom toString() defined)

With Mysql - Return the output of AES_ENCRYPT as string "0x8DBADD..."

In Mysql the function AES_ENCRYPT() returns a hex like:
0x8DBADD32FD0FAB62232104DEB9D56246
How can I return it as string:
"0x8DBADD32FD0FAB62232104DEB9D56246"
so for example I can right() to remove the first two characters: "0x"
I tried CAST but that converts the HEX to string. What I need is the string literal of the Hex
You can use HEX() to make the conversion and CONCAT() to add the prefix:
SELECT CONCAT('0x', HEX(0x8DBADD32FD0FAB62232104DEB9D56246)) AS hex_dump;

mySql JSON string field returns encoded

First week having to deal with a MYSQL database and JSON field types and I cannot seem to figure out why values are encoded automatically and then returned in encoded format.
Given the following SQL
-- create a multiline string with a tab example
SET #str ="Line One
Line 2 Tabbed out
Line 3";
-- encode it
SET #j = JSON_OBJECT("str", #str);
-- extract the value by name
SET #strOut = JSON_EXTRACT(#J, "$.str");
-- show the object and attribute value.
SELECT #j, #strOut;
You end up with what appears to be a full formed JSON object with a single attribute encoded.
#j = {"str": "Line One\n\tLine 2\tTabbed out\n\tLine 3"}
but using JSON_EXTRACT to get the attribute value I get the encoded version including outer quotes.
#strOut = "Line One\n\tLine 2\tTabbed out\n\tLine 3"
I would expect to get my original string with the \n \t all unescaped to the original values and no outer quotes. as such
Line One
Line 2 Tabbed out
Line 3
I can't seem to find any JSON_DECODE or JSON_UNESCAPE or similar functions.
I did find a JSON_ESCAPE() function but that appears to be used to manually build a JSON object structure in a string.
What am I missing to extract the values to the original format?
I like to use handy operator ->> for this.
It was introduced in MySQL 5.7.13, and basically combines JSON_EXTRACT() and JSON_UNQUOTE():
SET #strOut = #J ->> '$.str';
You are looking for the JSON_UNQUOTE function
SET #strOut = JSON_UNQUOTE( JSON_EXTRACT(#J, "$.str") );
The result of JSON_EXTRACT() is intentionally a JSON document, not a string.
A JSON document may be:
An object enclosed in { }
An array enclosed in [ ]
A scalar string value enclosed in " "
A scalar number or boolean value
A null — but this is not an SQL NULL, it's a JSON null. This leads to confusing cases because you can extract a JSON field whose JSON value is null, and yet in an SQL expression, this fails IS NULL tests, and it also fails to be equal to an SQL string 'null'. Because it's a JSON type, not a scalar type.

Identifying variable type in GNU Octave

When practicing with Octave I created a variable with the name my_name = ["Andrew"] and upon asking Octave to interpret whether it was a string it outputted a '0'. Again when using the typeinfo(my_name) I got ans = string. Why am I getting this sort of output?
octave:47> my_name = ["Andrew"]
my_name = Andrew
octave:48> isstring(my_name)
ans = 0
octave:49> typeinfo(my_name)
ans = string
According to the documentation (emphasis mine):
isstring (s)
Return true if s is a string array.
A string array is a data type that stores strings (row vectors of characters) at each element in the array. It is distinct from character arrays which are N-dimensional arrays where each element is a single 1x1 character. It is also distinct from cell arrays of strings which store strings at each element, but use cell indexing ‘{}’ to access elements rather than string arrays which use ordinary array indexing ‘()’.
Programming Note: Octave does not yet implement string arrays so this function will always return false.
That is, isstring will always return false (or 0), no matter what the input is.
You should use ischar to determine if the input is a character array (==string).

importJSON and concatenate function not working together

I am trying to use concatentate to create the input parameters with a variable for the importJSON function. The concatenated string looks and works fine if I copy it into the importJSON function but if I reference the string as part of the function or use concatenate in the function I get an invalid argument error.
Here is the concatenate string. Cell I7 is the date. For example 2017-11-27.
=concatenate("""https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=demo""",",","""","/Time Series (Daily)/",I7,"/4. close""", ", ","""noHeaders""")
Here is the output string with the date variable:
"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=demo","/Time Series (Daily)/2017-11-27/4. close", "noHeaders"
This works:
=importJSON("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=demo","/Time Series (Daily)/2017-11-27/4. close", "noHeaders")
These dont work:
=importJSON(concatenate("""https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&apikey=demo""",",","""","/Time Series (Daily)/",I7,"/4. close""", ", ","""noHeaders"""))
=importJSON(K9) >> K9 is cell where the concatenate function is
The issue was with the extra set of quotes. When referencing a cell or using a formula within the importJSON function, quotes are not needed.