SystemVerilog $test$plusargs matches substring - system-verilog

We usually write testcases with VCS plusargs as follows
if($test$plusargs("Hello"))
do_hello_stimulus();
else if($test$plusargs("Hello1"))
do_hello1_stimulus();
But I found out $test$plusargs match even the substring. Even if we pass Hello1, it will call do_hello_stimulus(). Can anyone help me out how I should use to match exact string?
Thanks in advance

this is exactly the behavior defined in the standard. The $test$plusargs matches the prefix of an arg.
You can use the $value$plusargs instead to check the remainder of the string. Something like this:
if ($value$plusargs("hello%s", rest)) begin
if (rest == "")
$display("hello");
else
$display("hello: %s", rest);
end
else
$display("error");

Related

how to prevent logging warning in a .get(true , false) statement to appear even though it is true and not false

I am making an application which rarely uses the terminal for output. So, I found that the logging library was a great way to help debug faulty code as supposed to the print statement.
But, for this code, specifically the .get() statement at the bottom...
def process_variables(self, argument):
data = pd.read_excel(self.url, sheet_name=self.sheet)
data = pd.concat([data.iloc[2:102], data.iloc[107:157]]).reset_index()
fb = data.loc[0:99, :].reset_index()
nfb = data.loc[100:155, :].reset_index()
return {'fb': data.loc[0:99, :].reset_index(),
'nfb': data.loc[100:155, :].reset_index(),
'bi': data.loc[np.where(data['Unnamed: 24'] != ' ')],
'uni': data.loc[np.where(data['Unnamed: 25'] != ' ')],
'fb_bi': fb.loc[np.where(fb['Unnamed: 24'] != ' ')],
'fb_uni': fb.loc[np.where(fb['Unnamed: 25'] != ' ')],
'nfb_bi': nfb.loc[np.where(nfb['Unnamed: 24'] != ' ')],
'nfb_uni': nfb.loc[np.where(nfb['Unnamed: 25'] != ' ')],
}.get(argument, f"{logging.warning(f'{argument} not found in specified variables')}")
...returns this...
output
The output returns the default argument even though the switch-case argument was successful, given that it did return the pandas Data frame.
So how can I make it so it only appears when it wasn't found, as it should if it were just a string and not a logging-string method.
Thank you for your help in advance :)
Python evaluates the arguments for the arguments to a function before it calls the function. That's why your logging function will get called regardless of the result of get(). Another thing is your f-string is probably going to evaluate to "None" every time since logging.warning() doesn't return anything, which doesn't seem like what you intended. You should just handle this with a regular if statement like
variables = {
'fb': data.loc[0:99, :].reset_index(),
...
}
if argument in variables:
return variables[argument]
else:
logging.warning(f'{argument} not found in specified variables')

How to cut a string from the end in UIPATH

I have this string: "C:\Procesos\rrhh\CorteDocumentos\Cortados\10001662-1_20060301_29_1_20190301.pdf" and im trying to get this part : "20190301". The problem is the lenght is not always the same. It would be:
"9001662-1_20060301_4_1_20190301".
I've tried this: item.ToString.Substring(66,8), but it doesn't work sometimes.
What can I do?.
This is a code example of what I said in my comment.
Sub Main()
Dim strFileName As String = ""
Dim di As New DirectoryInfo("C:\Users\Maniac\Desktop\test")
Dim aryFi As FileInfo() = di.GetFiles("*.pdf")
Dim fi As FileInfo
For Each fi In aryFi
Dim arrname() As String
arrname = Split(Path.GetFileNameWithoutExtension(fi.Name), "_")
strFileName = arrname(arrname.Count - 1)
Console.WriteLine(strFileName)
Next
End Sub
You could achieve this using a simple regular expressions, which has the added benefit of including pattern validation.
If you need to get exactly eight numbers from the end of file name (and after an underscore), you can use this pattern:
_(\d{8})\.pdf
And then this VB.NET line:
Regex.Match(fileName, "_(\d{8})\.pdf").Groups(1).Value
It's important to mention that Regex is by default case sensitive, so to prevent from being in a situations where "pdf" is matched and "PDF" is not, the patter can be adjusted like this:
(?i)_(\d{8})\.pdf
You can than use it directly in any expression window:
PS: You should also ensure that System.Text.RegularExpressions reference is in the Imports:
You can achieve it by this way as well :)
Path.GetFileNameWithoutExtension(Str1).Split("_"c).Last
Path.GetFileNameWithoutExtension
Returns the file name of the specified path string without the extension.
so with your String it will return to you - 10001662-1_20060301_29_1_20190301
then Split above String i.e. 10001662-1_20060301_29_1_20190301 based on _ and will return an array of string.
Last
It will return you the last element of an array returned by Split..
Regards..!!
AKsh

Inline if condition with nil in swift

I am trying to use inline if condition as follows:
topDisplay.text = topDisplay.text!.rangeOfString(".") ? "Sth for true" : "Sth for false"
The idea here is if there is "." in the topDisplay.text! then do something, if not, do something else. The method, rangeOfString, returns nil if no "." is found. So I am wondering is it possible to check nil within inline condition expression.
((btw, you might find out that I am trying to add "." button for calculator assignment in Stanford's online course, and to use only one line to implement this function as the hint describes))
So I am wondering is it possible to check nil within inline condition expression.
Sure. rangeOfString(".") != nil is a boolean expression which can
be used as the condition in the conditional expression:
topDisplay.text = topDisplay.text!.rangeOfString(".") != nil ? "Sth for true" : "Sth for false"

If Condition followed by a for loop not executing in Xquery

In one of the SOAP responses, I was trying to use the following Xquery code to check a condition followed by for loop. I was trying to get a count of some element and then use the if condition and based on that if condition, it should execute the for loop. However there is an exception that shows up .
Here is my Xquery bit in the SOAP UI.
declare variable $datesList := ("2013-01-01-00.30.00","2013-01-01-01.00.00","2013-01-01-01.30.00","2013-01-01-02.00.00","2013-01-01-02.30.00","2013-01-01-03.00.00","2013-01-01-03.30.00","2013-01-01-04.00.00");
<res>
{
let $mcId1 :=count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/mL)
let $mcId2 :=count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[2]/mL)
if($mcId1=8)
{
for $mlList in //ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/intervals/mL
return(if($mcId1 > $mcId2)
then <text>true</text>
else <text>false</text>)
}
}
Here is the exception that appears during run time.
RuntimeException:java.lang.reflect.InvocationTargetException
So I want to seek advice from the seniors and gurus, if the piece of Xquery code is correct?
Thanks much in advance.
There are multiple syntax errors in your query:
let clauses have to be part of a FLWOR expression, which always ends with a return clause.
if cannot be used without then and else and does not use curly braces.
The opening tag <res> needs a matching closing tag </res> at the end of the query.
The corrected query looks like this:
declare variable $datesList := (
"2013-01-01-00.30.00", "2013-01-01-01.00.00",
"2013-01-01-01.30.00", "2013-01-01-02.00.00",
"2013-01-01-02.30.00", "2013-01-01-03.00.00",
"2013-01-01-03.30.00", "2013-01-01-04.00.00"
);
<res>{
let $mcId1 := count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/mL)
let $mcId2 := count(//ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[2]/mL)
return if($mcId1 = 8) then (
for $mlList in //ZZQAD2UsageTransactionSVC/usagePeriods/usagePeriodsList/SQs/SQsList[1]/intervals/mL
return if($mcId1 > $mcId2)
then <text>true</text>
else <text>false</text>
) else ()
}</res>

iPhone/Objective-C - Searching for a specific word within a string

Is there a way to search for specific words within a string in Objective-C?
Let's say I have the following sentence:
thequickbrownfox
If I wanted to search for "quick" within the sentence. What would be the best way to achieve this?
Thanks for your help.
if ([myString rangeOfString:stringToSearch].location != NSNotFound) {
// stringToSearch is present in myString
}
You can use NSString::rangeOfString for this.
From the docs -
Return Value
An NSRange structure giving the location and length in the receiver of the first occurrence of aString. Returns {NSNotFound, 0} if aString is not found or is empty (#"").