I am having a field with string values as "First Middle Last" and i want to show the initial characters from this string as "FML"
how can i do it in terms of ssrs expression ?
Assuming the field MyString always has 3 words the following will find the first character of the First, Second and Last words. This admittedly doesn't handle instances where there are more or less than 3 words, but hopefully should get you started if you require more finesse.
=Left(Fields!MyString.Value, 1) + " " +
Left(Mid(Fields!MyString.Value, InStr(Fields!MyString.Value, " ") + 1), 1) + " " +
Left(Mid(Fields!MyString.Value, InStrRev(Fields!MyString.Value, " ") + 1), 1)
Edit
To cope with the possiblity of only two words (as suggested in the commetns below) a check for the index of the spaces could be used to ensure that they are not the same, and thus 3 words exist. This would make the code as follows
=Left(Fields!MyString.Value, 1) + " " +
Left(Mid(Fields!MyString.Value, InStr(Fields!MyString.Value, " ") + 1), 1) +
iif(InStrRev(Fields!MyString.Value, " ") > InStr(Fields!MyString.Value, " "),
" " + Left(Mid(Fields!MyString.Value, InStrRev(Fields!MyString.Value, " ") + 1), 1),
"")
Related
I am using Tradingview Pinescript 4.0.
This message was made with reference to :
https://stackoverflow.com/questions/66926863/combining-data-from-different-tradingview-4-0-indicators-for-the-purpose-of-crea
Basically, what I would like to do is use Tradingview 4.0 Pinescript Strategies with the Tradingview Webhook Alert system.
The closest I have seen that provides a hint a to how one can do this is found in this particular video (for a different product):
https://support.mudrex.com/hc/en-us/articles/360050211072-Automating-an-alert-from-a-Strategy-on-TradingView
It would use something like the "comment" below:
// strategy.entry(id=tostring(randomNumber), long=false,
comment="{"id" : " + tostring(randomNumber) + ", "action" :
"reverse_short_to_long"}")
I need to send JSON from the Strategy as part of the Web alert. According to the video, one would use something like:
{{ strategy.comment }}
Are there any solid examples as to how this could be done?
Tradingview sends the alert as JSON if the string is formatted as JSON. I suggest using the alert() function instead of alertcondition. It's then easy to construct a string in a JSON format however you want. Here's a nasty function I use to generate alerts.
customalert(_name, _symbol, _type, _asset_type, _action, _risk_value, _risk_percent, _sl, _tp1,_tp1_percent, _tp2, _tp2_percent, _message) =>
alert_array = array.new_string()
if _name != ''
array.push(alert_array, '"Name": "' + _name + '"')
if _symbol != ''
array.push(alert_array, '"Symbol": "' + _symbol + '"')
if _type != ''
array.push(alert_array, '"Type": "' + _type + '"')
if _asset_type != ''
array.push(alert_array, '"Asset Type": "' + _asset_type + '"')
if _action != ''
array.push(alert_array, '"Action": "' + _action + '"')
if _risk_value != 0
array.push(alert_array, '"Risk Value": "' + tostring(_risk_value) + '"')
if _risk_percent != 0
array.push(alert_array, '"Risk Percentage": "' + tostring(_risk_percent) + '"')
if _tp1 != 0
array.push(alert_array, '"Take Profit 1 Level": "' + tostring(_tp1) + '"')
if _tp1_percent != 0
array.push(alert_array, '"Take Profit 1 Percent": "' + tostring(_tp1_percent) + '"')
if _tp2 != 0
array.push(alert_array, '"Take Profit 2 Level": "' + tostring(_tp2) + '"')
if _tp2_percent != 0
array.push(alert_array, '"Take Profit 2 Percent": "' + tostring(_tp2_percent) + '"')
if _sl != 0
array.push(alert_array, '"Stop Loss Level": "' + tostring(_sl) + '"')
if _message != ''
array.push(alert_array, '"Message": "' + _message + '"')
alertstring = '{' + array.join(alert_array,', ') + '}'
alert(alertstring, alert.freq_once_per_bar_close)
You don't need to do anything complex though, the most important line is the alertstring = '{' + array.join(alert_array,', ') + '}'
You just need to make sure the string starts and ends with curly braces and is properly formatted JSON.
Could just as easily:
alert('{"Symbol": "' + syminfo.ticker + '", "Action": "Entry"}', alert.freq_once_per_bar_close)
You just need to be careful with your double and single quotes.
Also, this is explained if you go to set up an alert and click the option to learn more about alerts, at least the fact that formatting as JSON is what determines whether the alert is sent as text or JSON. As for the {{}}s, those are used to send a limited set of values for use with the alertcondition() function, and I don't really see an advantage to using them vs tostring() with alert().
Another thing to keep in mind is that this necessitates sending your data as strings, so you will need to make sure to convert back to ints and floats as necessary on the server side.
I've just started using Blazor and Razor pages.. it's a lot better than my old plain html pages I was building. But I'm having a problem converting my strings of html I build into actual HTML. Now, this works if I copy and paste my string and save that as an html page. It displays as html no problem. However, when I try to get my Razor page to display it, it displays as plain text. Even trying the trick:
<div>
#(new HtmlString(htmlString))
</div>
displays plain text. This is going to be painful as it's kind of long, but here is the string I'm trying to convert:
"<pre><br><b>STATION INFO</b><br><br> Extension: 34263 Lock Messages? n BCC: 0 <br> Type: 9630 Security Code: 12345 TN: 1<br> Port: S17746 Coverage Path 1: 132 COR: 44<br> Name: Lastname, Firstname Coverage Path 2: COS: 1<br><br><b>STATION OPTIONS</b><br> Time of Day Lock Table: <br> Loss Group: 19 Personalized Ringing Pattern: 1<br> Message Lamp Ext: 34263<br> Speakerphone: 2-way Mute Button Enabled? y<br> Display Language: english Expansion Module? <br> Survivable GK Node Name: <br> Survivable COR: internal Media Complex Ext: <br> Survivable Trunk Dest? IP SoftPhone? y<br><br> IP Video Softphone? n<br><br> Customizable Labels? y<br><br><br> <b>FEATURE OPTIONS</b><br><br> LWC Reception: spe Auto Select Any Idle Appearance? n<br> LWC Activation? y Coverage Msg Retrieval? y<br> LWC Log External Calls? n Auto Answer: none<br> CDR Privacy? n Data Restriction? n<br> Redirect Notification? y Idle Appearance Preference? n<br> Per Button Ring Control? n Bridged Idle Line Preference? n<br> Bridged Call Alerting? n Restrict Last Appearance? y<br> Active Station Ringing: continuous<br> EMU Login Allowed? n<br> H.320 Conversion? n Per Station CPN - Send Calling Number? y<br> Service Link Mode: as-needed EC500 State: unknown<br> Multimedia Mode: enhanced Audible Message Waiting? n<br> MWI Served User Type: sip-adjunct Display Client Redirection? n</pre><br>"
it's being built by my method that returns a string. For fun, here is my method:
public static string CreateStationString(List<StarfishStation> html)
{
var myHTML1 =
"<pre>" + "<br>" +
"<b>STATION INFO</b>" + "<br>" +
"" + "<br>" +
" Extension: " + html[0].DeftyExtension.PadRight(29, ' ') + "Lock Messages? " + html[0].DeftyMessagelock.PadRight(9, ' ') + "BCC: 0 <br>" +
" Type: " + html[0].DeftyDisplaysettype.PadRight(29, ' ') + "Security Code: " + html[0].DeftySecuritycode.PadRight(10, ' ') + "TN: " + html[0].DeftyTenantpartitionnumber + "<br>" +
" Port: " + html[0].DeftyPort.PadRight(27, ' ') + "Coverage Path 1: " + html[0].DeftyCoveragepath.PadRight(9, ' ') + "COR: " + html[0].DeftyCor + "<br>" +
" Name: " + html[0].DeftyName.PadRight(27, ' ') + "Coverage Path 2: " + html[0].DeftyCoverage2path.PadRight(9, ' ') + "COS: " + html[0].DeftyCos + "<br><br>" +
"<b>STATION OPTIONS</b>" + "<br>" +
" Time of Day Lock Table: <br>" +
" Loss Group: " + html[0].DeftyLossgroup + " Personalized Ringing Pattern: " + html[0].DeftyPersonalizedringpattern + "<br>" +
" Message Lamp Ext: " + html[0].DeftyMessagewaitlamplextension + "<br>" +
" Speakerphone: " + html[0].DeftySpeakerphone + " Mute Button Enabled? " + html[0].DeftyMutebutton + "<br>" +
" Display Language: " + html[0].DeftyLanguage.PadRight(32, ' ') + "Expansion Module? " + html[0].DeftyExpansionmodule + "<br>" +
" Survivable GK Node Name: <br>" +
" Survivable COR: internal Media Complex Ext: <br>" +
" Survivable Trunk Dest? IP SoftPhone? " + html[0].DeftyIpsoftphone + "<br>" +
"" + "<br>" +
" IP Video Softphone? n<br>" +
"<br>" +
" Customizable Labels? y<br><br>" +
"<br>" +
" <b>FEATURE OPTIONS</b><br><br>" +
" LWC Reception: " + html[0].DeftyLwcreception.PadRight(20, ' ') + "Auto Select Any Idle Appearance? " + html[0].DeftyIdleappearancepreference + "<br>" +
" LWC Activation? " + html[0].DeftyLwcactivation.PadRight(29, ' ') + "Coverage Msg Retrieval? " + html[0].DeftyCoveragemessageretrieval + "<br>" +
" LWC Log External Calls? " + html[0].DeftyLwclogexterncall.PadRight(40, ' ') + "Auto Answer: " + html[0].DeftyAutoanswer + "<br>" +
" CDR Privacy? " + html[0].DeftyCdrprivacy.PadRight(35, ' ') + "Data Restriction? " + html[0].DeftyDatarestriction + "<br>" +
" Redirect Notification? " + html[0].DeftyRedirectnotification.PadRight(25, ' ') + "Idle Appearance Preference? " + html[0].DeftyIdleappearancepreference + "<br>" +
" Per Button Ring Control? " + html[0].DeftyPerbuttonnringcontrol.PadRight(23, ' ') + "Bridged Idle Line Preference? n" + "<br>" +
" Bridged Call Alerting? " + html[0].DeftyBridgecallalerting.PadRight(27, ' ') + "Restrict Last Appearance? " + html[0].DeftyRestrictlastappearance + "<br>" +
" Active Station Ringing: " + html[0].DeftyActivestationringing + "<br>" +
" EMU Login Allowed? " + html[0].DeftyEMULoginAllowed + "<br>" +
" H.320 Conversion? " + html[0].DeftyH320conv.PadRight(14, ' ') + "Per Station CPN - Send Calling Number? " + html[0].DeftyCpnrestriction + "<br>" +
" Service Link Mode: " + html[0].DeftyServicelinkmode.PadRight(31, ' ') + "EC500 State: unknown<br>" + //check ec500
" Multimedia Mode: " + html[0].DeftyMultimediamode.PadRight(28, ' ') + "Audible Message Waiting? " + html[0].DeftyAudiblemessagewaiting + "<br>" +
" MWI Served User Type: " + html[0].DeftyMessagewaitindicatortype.PadRight(25, ' ') + "Display Client Redirection? n</pre><br>";
return myHTML1;
}
When I look at the frame source, here's what I see:
<div>
<pre><br><b>STATION INFO</b><br><br> Extension: 34263 Lock Messages? n BCC: 0 <br> Type: 9630 Security Code: 12345 TN: 1<br> Port: S17746 Coverage Path 1: 132 COR: 44<br> Name: Lastname Firstname Coverage Path 2: COS: 1<br><br><b>STATION OPTIONS</b><br> Time of Day Lock Table: <br> Loss Group: 19 Personalized Ringing Pattern: 1<br> Message Lamp Ext: 34263<br> Speakerphone: 2-way Mute Button Enabled? y<br> Display Language: english Expansion Module? <br> Survivable GK Node Name: <br> Survivable COR: internal Media Complex Ext: <br> Survivable Trunk Dest? IP SoftPhone? y<br><br> IP Video Softphone? n<br><br> Customizable Labels? y<br><br><br> <b>FEATURE OPTIONS</b><br><br> LWC Reception: spe Auto Select Any Idle Appearance? n<br> LWC Activation? y Coverage Msg Retrieval? y<br> LWC Log External Calls? n Auto Answer: none<br> CDR Privacy? n Data Restriction? n<br> Redirect Notification? y Idle Appearance Preference? n<br> Per Button Ring Control? n Bridged Idle Line Preference? n<br> Bridged Call Alerting? n Restrict Last Appearance? y<br> Active Station Ringing: continuous<br> EMU Login Allowed? n<br> H.320 Conversion? n Per Station CPN - Send Calling Number? y<br> Service Link Mode: as-needed EC500 State: unknown<br> Multimedia Mode: enhanced Audible Message Waiting? n<br> MWI Served User Type: sip-adjunct Display Client Redirection? n</pre><br>
</div>
Sorry this is so long.. but can anyone please help me out?
Thanks!
Dave M.
Wow ok.. so stumbled upon the answer:
<div>
#((MarkupString)htmlString)
</div>
instead of:
<div>
#(new HtmlString(htmlString))
</div>
found the answer here: Convert plain text with html tags to html string and render it in Blazor
Following SQL statement is creating an error with message :
"Message: Fatal error encountered during command execution."
"Inner exception: Parameter '#LastUserID' must be defined."
If I directly use LAST_INSERT_ID() instead of LastUserID, it always returns zero (hence fails at second insert) when executed like this.
I don't see my syntax is different than in mySQL document.
Could some one help me ?
string Query = #"INSERT INTO login (" +
"LOGIN_EMAIL," +
"LOGIN_PASSWORD," +
"LOGIN_SALT," +
"LOGIN_LAST_LOGIN_DATE," +
// "LOGIN_LAST_LOGIN_LOCATION," +
"LOGIN_ACCOUNT_STATUS," +
"LOGIN_LOGIN_ATTEMPTS," +
"LOGIN_CREATED_DATE) " +
"VALUES (" +
"#Parameter2," +
"#Parameter3," +
"#Parameter4," +
"#Parameter5," +
// "#Parameter6," +
"#Parameter6," +
"#Parameter7," +
"#Parameter8); " +
"SET #LastUserID = LAST_INSERT_ID(); " +
"INSERT INTO user_role (" +
"USER_ROLE_USER_ID," +
"USER_ROLE_ROLE," +
"USER_ROLE_STATUS," +
"USER_ROLE_CREATED_DATE) " +
"SELECT " +
"#LastUserID," +
"#Parameter9," +
"#Parameter10," +
"#Parameter11 " +
"FROM dual WHERE NOT EXISTS (SELECT USER_ROLE_USER_ID FROM user_role " +
"WHERE USER_ROLE_USER_ID = #LastUserID AND USER_ROLE_ROLE = #Parameter9)";
MySqlCommand oCommand = new MySqlCommand(Query, oMySQLConnecion);
oCommand.Transaction = tr;
Create a procedure in which you first do your insert, cache the last inserted id, do the other insert and let it print out your parameters with a bool if your last insert worked or not. That way you can debug it properly.
In general you should avoid concatinating strings to generate sql-commands or you might get troubles with parameters containing unexpected characters or be hit by a injection.
Simple fix : Replace "$LastUserID" with "$'LastUserID'". The ephostophy makes the difference.
I am trying to develop a package which takes a string (in the format 1.02.3.04 or 01.02.03.4 and lots of other permutations) and amends this based upon the following rules
if the second character is a "." then pad the first group with a 0
FINDSTRING([mycolname],".",1) returns the position of the first "." and for all values of 2 then apply this rule and amend the string eg if 1.2.3.4 will return 2 the string should be 01.2.3.4
if the second instance of "." is 5 FINDSTRING([mycolname],".",2) then add a 0 in after the third character eg 01.02.3.4
if the third instance of "." is 8 FINDSTRING([mycolname],".",3) then add 0 in after the 6th character
I am a little stuck with some of the logic !
anyone help ??
in SSIS 2012 can be achieved with a one-liner Derived Column:
RIGHT("00" + TOKEN("1.02.3.04",".",1),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",2),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",3),2) + "." + RIGHT("00" + TOKEN("1.02.3.04",".",4),2)
When I publish my flash files, I get this message:
WARNING: excess bytes: -616, Tag: DefineFont3, Index: 5
WARNING: excess bytes: 2, Tag: DefineFont3, Index: 36
What are these warning? Anything related to these warning?
Yesterday is still fine, but today I get this.
Maybe one of your libraries are using the SWFTimeline. It's source code contains the very same warning.
The following code snippet is from the SWFTimeline.as file, starting at line 84.
// Adjust position (just in case the parser under- or overflows)
if(data.position != pos + tagHeader.tagLength) {
trace("WARNING: excess bytes: " +
(data.position - (pos + tagHeader.tagLength)) + ", " +
"Tag: " + tag.name + ", " +
"Index: " + (tags.length - 1)
);
data.position = pos + tagHeader.tagLength;
}
It seens to be caused by malformed tags or file corruptions, maybe other reasons too.