The below is my code entered to Swift 2 and getting the error saying "postfix is reserved".
Can anyone tell me how this went wrong?
if (PFUser.currentUser() == nil){
self.loginViewController.fields =
PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton
Can you ensure that your OR compound expression does not contain spurious spaces?. I can spot one before the .LogInButton. I have corrected it here. Please check-
if (PFUser.currentUser() == nil){
self.loginViewController.fields =
PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton
Related
I am trying to iterate over an array $dailyTasks to find 'Blank' i.e. '' values in the EmployeeName column and inject names from another array into those empty values.
Example of what the array looks like before the for loop starts:
| Task | EmployeeName | EmployeeName2 |
|-------|--------------|---------------|
| Task1 | | |
| Task2 | Person Y | |
| Task3 | | |
| Task4 | Person Z | Person X |
This is my for loop code that produces an undesired result. $randomisedUsers is an Object[]
$randomisedUsers | Group-Object { $_ -in ($randomisedUsers | Select-Object -Last 2) } | ForEach-Object {
if ($_.Name -eq 'True') {
for ($i = 0; $i -lt $dailyTasks.Count; $i++) {
if ($dailyTasks[$i].Task -eq 'Task4') {
$dailyTasks[$i].EmployeeName = $_.Group.EmployeeName[0]
$dailyTasks[$i].EmployeeName2 = $_.Group.EmployeeName[1]
}
}
} else {
for ($i = 0; $i -lt $dailyTasks.Count; $i++) {
if ($dailyTasks[$i].EmployeeName -eq '') {
if ($_.Count -gt '1') {
for ($x = 0; $x -lt $_.Group.EmployeeName.Count; $x++) {
$dailyTasks[$i].EmployeeName = $_.Group.EmployeeName[$x]
}
} else {
$dailyTasks[$i].EmployeeName = $_.Group.EmployeeName
}
}
}
}
}
Result:
| Task | EmployeeName | EmployeeName2 |
|-------|--------------|---------------|
| Task1 | Person A | |
| Task2 | Person Y | |
| Task3 | Person A | |
| Task4 | Person Z | Person X |
The problem here is that $_.Group.EmployeeName contains two objects but for whatever reason the result table doesnt populate Person B in the array:
$_.Group.EmployeeName
{Person A, Person B}
The desired result in this case is:
| Task | EmployeeName | EmployeeName2 |
|-------|--------------|---------------|
| Task1 | Person A | |
| Task2 | Person Y | |
| Task3 | Person B | |
| Task4 | Person Z | Person X |
Im not completely sure where im going wrong in my for loops and i've been stuck on this for a while...
TIA
I would personally use something like this:
$csv = #'
Task,EmployeeName,EmployeeName2
Task1,,
Task2,Person Y,
Task3,,
Task4,Person Z,Person X
'# | ConvertFrom-Csv
$fillEmployees = [System.Collections.ArrayList]#(
'Person A'
'Person B'
)
foreach($line in $csv)
{
if([string]::IsNullOrWhiteSpace($line.EmployeeName))
{
$line.EmployeeName = $fillEmployees[0]
$fillEmployees.RemoveAt(0)
}
}
The flow is quite simple, if the loop finds a value in EmployeeName that is null or has white spaces it will replace that value with the index 0 of $fillEmployees and then remove that index 0 from the list.
It's hard to tell what you're trying to accomplish with your code, but if you have an array of the type System.Array filled with random names which will be used to fill this empty values on EmployeeName you can convert that Array to an ArrayList which will allow you to use the .RemoveAt(..) method:
PS /> $fillEmployees = 0..10 | ForEach-Object {"Employee {0}" -f [char](Get-Random -Minimum 65 -Maximum 90)}
PS /> $fillEmployees
Employee J
Employee S
Employee D
Employee P
Employee O
Employee E
Employee M
Employee K
Employee R
Employee F
Employee A
PS /> $fillEmployees.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Attempting to Remove an item from an Array would result in the following:
PS /> $fillEmployees.RemoveAt(0)
Exception calling "RemoveAt" with "1" argument(s): "Collection was of a fixed size."
At line:1 char:1
...
...
However if convert it to an ArrayList (not convert it but copy it):
PS /> $fillEmployees = [System.Collections.ArrayList]$fillEmployees
PS /> $fillEmployees.RemoveAt(0)
My example code output:
time | name | status | s_used | s_max |
+------------+-------------+-----------+------------+-----------+
| 1482222363 | asf | Closed | 0/16 | 0 |
| 1482222363 | as0 | Available | 4/16 | 4 |
I have attached the part of my output which is generated using perl cgi script and mysql database.
My query is how to take denominator value from the column s_used and store only the denominator values in the s_max column using perl.
3.I had attached the following part of code which i tried.
if($i == 4){
if(/s_used/){
print;
}
else{
chomp();
my($num,$s_max)=split /\//,$table_data{2}{'ENTRY'};
print $s_max;
}
}
Code Explanation:
$i == 4 is the column where should I store the variable.
I got time column from the sql database $time, name I got from $table_data{0}{'ENTRY'}, status from $table_data{1}{'ENTRY'}, s_used from $table_Data{2}{'ENTRY'}.
Expected output:
time | name | status | s_used | s_max |
+------------+-------------+-----------+------------+-----------+
| 1482222363 | asf | Closed | 0/16 | 16 |
| 1482222363 | as0 | Available | 4/16 | 16 |
Seems your code "my($num,$s_max)=split /\//,$table_data{2}{'ENTRY'};" is right.
Somehow the value $s_max at the time it's writing to the DB is incorrect. Since you did not post the portion of code to show the part $s_max writing back to the DB, you need to check what value is in $s_max (e.g. printing the $s_max value) at the time right before writing it back to DB. From there, please try to trace back why an incorrect value is assigned to $s_max. Then, the problem would be solved.
With the following program, I get a big list out of print~.
I want to a get the second value from this list.
How to get this second value and print it with print and not print~?
[print~] will always print the entire signal-block (in your case 128 values).
to get a specific sample, you could instead use a table, feed the monitored signal into it, and retrieve the value(s) you are interested:
...
|
[tabsend~ $0-foo]
[table $0-foo 128]
[2(
|
[tabread $0-foo]
|
[print]
note: unlike with [print~], which will only generate output at the next signal block, this will output the data immediately (that is: it will take the signal data from the last signal block).
to get the next signal-block, you can replace the lower part of the suggested solution with something like the following:
[bang~] [2(
| |
| [r $0-next] |
| | |
[spigot] [t b f]
| | |
[t f b] [1( |
| | | |
| [0( [s $0-next] |
| | |
| [s $0-next] |
| |
[float ]
|
[tabread $0-foo]
|
...
(the patch uses [s/r $0-next] to avoid cross-over connection lines in the ascii graphics; in practice you probably want to use straight connections instead)
it's probably best to encapsulate the entire thing into an abstraction.
I want to check whether the variable is storing blank value or not.
I tried out comparing it with '' or "" or NULL or null, but does not work.
You can try out below solution
storeValue | element | test
store | | j (blank value)
gotoIf | storedVars['test']==storedVars['j'] | true
getEval | alert("test Variable Value is not blank")
gotolabel | finish
label | true
getEval | alert("test Variable Value is blank")
label | finish
You can also use verifyEval command for this. Try following script,
verifyEval | this.page().findElement("id=gbqfq").value == '' | true
So, I have two fields I am indexing:
| NAME | TYPE |
-------------------------------------
|Texas Steak | Restaurant |
|Bone Digs Restaurant | Restaurant |
|Rain Sushi | Restaurant |
|Brazil Steakhouse | Restaurant |
|Alfredos | Restaurant |
|Mediterranean Corner | Restaurant |
|Korean Taqueria | Restaurant |
|Orlando Cantina | Restaurant |
|Boomer Bar and Grill | Restaurant |
|Top Spice | Restaurant |
|Tamarind | Restaurant |
I am indexing in the following fashion:
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
//let lucene search for numbers as well as words
try {
$index = Zend_Search_Lucene::create('data/');
} catch(Zend_Search_Lucene_Exception $e){
echo "Unable {$e->getMessage()}";
}
$mdlPage = new Application_Model_DbTable_Business();
$currentPages = $mdlPage->fetchAll();
if($currentPages->count() >= 0) {
foreach ($currentPages as $p) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::text('business_name', $p->business_name));
$doc->addField(Zend_Search_Lucene_Field::text('primary_category',$p->primary_category));
$index->addDocument($doc);
}
}
$index->commit();
$index->optimize();
$this->view->indexSize = $index->numDocs();
Now, I am querying the index in the following fashion:
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->addTerm(new Zend_Search_Lucene_Index_Term($keyword,'business_name'),null);
$query->addTerm(new Zend_Search_Lucene_Index_Term($keyword,'primary_category'),null);
echo $query;
try {
$results = $index->find($query);
}
catch (Zend_Search_Lucene_Exception $e) {
echo "Unable {$e->getMessage()}";
}
Here is the odd thing. If I query for 'thai' or any word that is in field business_name I get results. But once I query for 'restaurant' my screen does not resolve but to a white screen. If I change my code to this:
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
//$query->addTerm(new Zend_Search_Lucene_Index_Term($keyword,'business_name'),null);
$query->addTerm(new Zend_Search_Lucene_Index_Term($keyword,'primary_category'),null);
Then I do get results. I don't get what Lucene does not like. Is it my data? Is it how I am creating my query? Or is it how I am creating my index?