On Text $date mirc - irc

How can I use on text $date on mirc?
I am trying to do something like this.
on *:text:$(* %date *):#: {
var %date = $date(yy-mm-dd)
if ($nick == user) {
do something
}
}

You can encapsulate the text to listen to in $() to evaluate it before matching it to the incoming message:
on *:TEXT:$($date(yy-mm-dd)):#:{
msg $chan That's today!
}

i recommend this
on *:text:$($iif($+(*,$date(yy-mm-dd),*) iswm $strip($1-),$1-)):#:{
if ($nick == user) { do something }
}
the on text will strip the color codes at $1- and return all the text colors stripped.
by the way, it will match the date at any position of the line, not just at the beginning

Related

Restricting space at the beginning

This is function which is I'm using at liveChange event:
if (oEvent.mParameters.value.indexOf(" ") === 0) {
sap.m.MessageToast.show("Space character is not allowed");
oEvent.preventDefault();
return false;
}
By using this code I have to restrict the whitespaces at the beginning in the input field. I tried a lot, I'm getting the message but it is taking the whitespace. How can I make an input field display only message and it should not take whitespaces.
To "invasively" remove the whitespace in the beginning of the input, you can do something like this:
onLiveChange = function(oEvent) {
var sValue = oEvent.getParameter('value');
if (sValue[0] === ' ') { // or use sValue.match(/^ /)
oEvent.getSource().setValue(sValue.trimStart());
sap.m.MessageToast.show("Space character is not allowed");
}
}
Also have a look at this SAPUI5 Demokit Sample as well as the validationError and validationSuccess events of class `sap.ui.core.Core' to get an idea of the recommended way of handling validation.

Parsing text File and extracting information in perl

I have a code with multiple functions
void fun_one()
{
tempa=10;
tempb=10;
}
void fun_two()
{
tempc=12;
tempd=13;
}
I want perl code that extracts function name if i input variable name;
say I search for "tempa", it should extract "fun_one" into a variable;
say I search for "tempd", it should extract "fun_two" into a variable;
I have extracted line number
open my $code, '<', 'code.txt' ;
my $keyword = "tempa";
my $regex = qr|\b($keyword)\b|;
while ($code>)
{
while (/$regex/g)
{
print "$.\n";
}
}
Output:3
I need some logic to extract fuction name.
thanks in advance
You might need a parser instead of just regexes.
But...
sub find_function_using_variable {
my $variable = shift;
my $last_func="";
while (<>) {
$last_func = $1 if m/void (\w+)\(\)/;
print $last_func."\n" if m/\Q$variable\E/;
}
}

NGUI avoid line-break in UIInput

Is there any way to avoid users to input line-breaks in UIInputs?
Do not want the user to be able to write line-breaks in username inputs, for example.
I searched for multiline attribute but it seems it only exists in UILabel objects.
Tried "validation:Username" but this option does not allow to write characters like "-", which is a valid username character of my application.
Thanks!
You can similarly limit your input field to a single line by setting the Max Lines property to 1 on the UILabel.
http://www.tasharen.com/forum/index.php?topic=6752.0
Had to check the UIInput.cs file to know how to ignore newlines, and I found this:
case KeyCode.KeypadEnter:
{
ev.Use();
bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
(onReturnKey == OnReturnKey.Default &&
label.multiLine && !ctrl &&
label.overflowMethod != UILabel.Overflow.ClampContent &&
validation == Validation.None);
if (newLine)
{
//Insert("\n");
}
else
{
UICamera.currentScheme = UICamera.ControlScheme.Controller;
UICamera.currentKey = ev.keyCode;
Submit();
UICamera.currentKey = KeyCode.None;
}
return true;
}
So in order to avoid newlines, you need to do:
UILabelObject.multiLine = false;
UIInputObject.onReturnKey = UIInput.OnReturnKey.Default;
Doing that, bool newLine becomes false and performs Submit();

avoid Number Format Exception while parseing to integer

I'm trying to check if the text area has only numbers or not, but i got this problem Number Format Exception while clicking on the Edit Button, any Ideas how to solve it.
ArrayList<CarRental> List= CarRent.getList();
String text=EditTF.getText().trim();
char [] txt=text.toCharArray();
Character a=null;
boolean isnotDigit=false;
int index;
for(int i=0;i<txt.length;i++)
{
if(!a.isDigit(txt[i]))
{
isnotDigit=true;
break;
}
else
{
isnotDigit=false;
continue;
}
}
if(isnotDigit==false)
{
index=Integer.parseInt(text.trim());
PrintList_Summary.setIndex(index);
EditDetails.nameTF.setText(List.get(index).getName());
EditDetails.sizeCOB.setSelectedItem(List.get(index).getSize());
EditDetails.daysTF.setText(List.get(index).getDays()+"");
if(List.get(index).getCarType().equalsIgnoreCase("Luxury"))
{
EditDetails.LuxRB.setSelected(true);
}
else if(List.get(index).CarType().equalsIgnoreCase("Truck"))
{
EditDetails.truckRB.setSelected(true);
}
if(List.get(index).getDriver())
{
EditDetails.yesRB.setSelected(true);
}
else
{
EditDetails.noRB.setSelected(true);
}
EditDetails.Frame.setVisible(true);
}
else
{
JOptionPane warning=new JOptionPane();
warning.showMessageDialog(null,"Element Index CAN ONLY be an INTEGER.","Invalid Index",WIDTH);
}
Use try catch to handle exceptions.
try{
index = Integer.parseInt(text.trim());
//etc
}catch(NumberFormatException ex){
//whatever happens when the exception is thrown (not an integer)
}
You can use that instead of the if(!a.isDigit(txt[i])) for. If it can't be parsed, then it will go intro the catch.
Also, you can use !isnotDigit instead of isnotDigit == false.
I would use String.matches() for your check instead of doing it yourself. Scrap the for-loop and change your if-condtion from isnotDigit==false to text.matches("[0-9]+"). After this Integer.parseInt(text) should definitly work.
This uses a regular expression to check if your string consists only of digits and at least one digit. For further reference on regular expression see the javadoc for Pattern.

Filemaker: No records match the request

I am newbie with filemaker. I am trying to set search function but something wrong and it returns No records match the request even if it is present there. Here is code
public function get_row($table, $search='')
{
$layout_object = $this->fm->getLayout($table);
if (FileMaker::isError($layout_object)) {
return array();
}
$request = $this->fm->newFindCommand($table);
if ($search)
{
$request->addFindCriterion($search['key'], 'hh#kkk.nn'); // hardcoded.
}
$result = $request->execute();
if (FileMaker::isError($result)) {
echo $result->getErrorString();
}
//.....Result: No records match the request
}
what I am doing wrong?
You need to escape the # symbol as it's a special character in Find mode to match any one character, so try this:
$request->addFindCriterion($search['key'], 'hh\#kkk.nn'); // hardcoded.