ABAP WebAS Active Codepage - html

I need to concatenate different lines in a string.
To do so, I need to use CR + LF hexadecimal characters.
The problem is that, when I'm using an 8 bit/char environment, I just need to do something like this:
constants : c_lf type x value '10'.
constants : c_cr type x value '13'.
data : g_html type string.
concatenate '<html>' c_cr c_lf into g_html.
but, when I'm in a 16 bit/char environment, the X variable does not represent the correct hexadecimal representation for CR and LF.
So, I should use something like this:
constants : c_lf(2) type x value '0010'.
constants : c_cr(2) type x value '0013'.
data : g_html type string.
concatenate '<html>' c_cr c_lf into g_html.
So, there is any way to find out the amount of bytes/char in use by ABAP WebAS?
Thanks!

The function TR_GET_IS_UNICODE_SYSTEM indicate if the system is using unicode or not.
It calls the CL_ABAP_CHAR_UTILITIES class to get the CHARSIZE attribute (bite/char) (by the way, this class contains a CR_LF public attribute...)
Regards
Guillaume

Related

Apache Nifi: Replacing values in a column using Update Record Processor

I have a csv, which looks like this:
name,code,age
Himsara,9877,12
John,9437721,16
Razor,232,45
I have to replace the column code according to some regular expressions. My logic is shown in a Scala code below.
if(str.trim.length == 9 && str.startsWith("369")){"PROB"}
else if(str.trim.length < 8){"SHORT"}
else if(str.trim.startsWith("94")){"LOCAL"}
else{"INT"}
I used a UpdateRecord Processor to replace the data in the code column. I added a property called /code which contains the value.
${field.value:replaceFirst('^[0-9]{1,8}$','SHORT'):replaceFirst('[94]\w+','OFF_NET')}
This works when replacing code's with
length less than 8 with "SHORT"
starting with 94 with "LOCAL"
I am unable to find a way to replace data in the column, code when it's equal to 8 digits AND when it starts with 0. Also how can I replace the data if it doesn't fall into any condition mentioned above. (Situation which the data should be replaced with INT)
Hope you can suggest a workflow or value to be added to the property in Update record to make the above two replacements happen.
There is a length and startsWith functions.
${field.value:length():lt(8):ifElse(
'SHORT', ${field.value:startsWith(94):ifElse(
'LOCAL', ${field.value:length():equals(9):and(${field.value:startsWith(369)}):ifElse(
'PROB', 'INT'
)})})}
I have put the line breaks for easy to recognize the functions but it should be removed.
By the way, the INT means that some string values to replace? Sorry for the confusion.
Well, if you want to regular expression only, you can try the below code.
${field.value
:replaceFirst('[0-9]{1,8}', 'SHORT')
:replaceFirst('[94]\w+', 'OFF_NET')
:replaceFirst('369[0-9]{6}', 'PROB')
:replace(${field.value}, 'INT')
}

In VHDL is there a way using std_texio to read elements of a .csv file and store them in a variable to then use?

I can currently use the readline and read function to read a line from the file and store the characters in variables governed by the size of the variable im putting them into for example if the first line of the file was
hello,world
and I wanted to store the two words in different variables I would do something along the lines of
file in_file : text open READ_MODE is "hello_world.csv";
variable in_line : line;
variable first_word : string(1to5);
variable second_word : string(1to5);
begin
readline(infile,inline);
read(inline,first_word);
read(inline,second_word);
however that is dependent upon the size of the elements I want to be able to generically read the first element before the comma and assign that to a variable then look for the next element until the next comma and store that in a different variable if that makes sense.
Many Thanks
The open source VUnit test framework has a standalone string operations package containing a split function
impure function split (
constant s : string;
constant sep : string;
constant max_split : integer := -1)
return lines_t;
that you can use to split a string (s) into its parts which are separated by sep. For example
parts := split("hello,world",",");
parts is a vector of elements of type line so parts[0].all would in this case equal hello. Have a look at the testbench for the package and look for the "Test split" test case to see the details on how the function handles various normal inputs and corner cases.
Since we use the line type rather than string we don't have to know the length of individual elements.
I'm one of the authors for VUnit.

Escape SQL statement passed to initWithFormat / stringWithFormat

I am writing an SQL statement class that will allow a user to create a properly formatted SQL statement string. This class will have a method -(id)initWithFormat:(NSString *)format, ... that needs to work just like the NSString variadic method. The one thing I want to change, however, is any NSString's passed as an argument must be automatically escaped by the initWithFormat.
For example, after initialising a statement like this (notice the string argument has a "'" that needs to be escaped):
MyStatement *statement = [[MyStatement alloc] initWithFormat:#"UPDATE myTable SET myField = %# WHERE myID = %lu", #"David's Room", 1234];
The resulting statement string should be:
#"UPDATE myTable SET myField = "David\'s Room WHERE myID = 1234"
Writing the function to escape a string is easy but I can't work out how to include this in the initWithFormat method. Can anyone tell me how to accomplish this? I have thought about emulating the NSString initWithFormat functionality by stepping through each character of the format string, finding any chars starting with % and somehow using a switch statement to append the correct type to a NSMutableString but this seems overly complicated (i.e. some format specifiers are more than 1 char e.g. Signed 16-bit integer %hi and the function should take into account positional specifiers such as %1$# etc).
All the variadic tutorials I have seen concentrate on nil-terminated lists and don't show how to emulate initWithFormat effectively (including the technical Q&A from Apple that is deceptively titled "How can I write a method that takes a variable number of arguments, like NSString's +stringWithFormat:?").
Thanks in advance.

MySQL integer comparison ignores trailing alpha characters

So lets just say I have a table with just an ID is an int. I have discovered that running:
SELECT *
FROM table
WHERE ID = '32anystring';
Returns the row where id = 32. Clearly 32 != '32anystring'.
This seems very strange. Why does it do this? Can it be turned off? What is the best workaround?
It is common behavior in most programming languages to interpret leading numerals as a number when converting a string to a number.
There are a couple of ways to handle this:
Use prepared statements, and define the placeholder where you are putting the value to be of a numeric type. This will prevent strings from being put in there at all.
Check at a higher layer of the application to validate input and make sure it is numeric.
Use the BINARY keyword in mysql (I'm just guessing that this would work, have never actually tried it as I've always just implemented a proper validation system before running a query) -
SELECT *
FROM table
WHERE BINARY ID = '32anystring';
You need to read this
http://dev.mysql.com/doc/refman/5.1/en/type-conversion.html
When you work on, or compare two different types, one of them will be converted to the other.
MySQL conversion of string->number (you can do '1.23def' * 2 => 2.46) parses as much as possible of the string as long as it is still a valid number. Where the first letter cannot be part of a number, the result becomes 0

mumps query related to %%

What is the meaning of I $E(R%%,I%%)>1 ? and why using %%?
Actually, if you are talking about Standard MUMPS (not any particular implementation)
the R%% is illegal syntax. I have seen the non-standard use of % in extensions to MUMPS, such as EsiObjects or InterSystems Cache Object Script, but the use in the question above is actually nonsense in standard MUMPS.
There is no particular significance to %%. Its just part of the variable name and I still don't understand MUMPS community obsession with using % in variable names and making them more obscure.
so the statement means IF $EXTRACT(R%%,I%%)>1 i.e if the extracted value from the string R%% at position I%% is greater than 1, do some more obscure stuff.
$EXTRACT(string,from) extracts a
single character in the position
specified by from. The from value can
be an integer count from the beginning
of the string, an asterisk specifying
the last character of the string, or
an asterisk with a negative integer
specifying a count backwards from the
end of the string.
Link to documentation: http://docs.intersystems.com/cache20102/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_fextract