My Question : How to Remove a value and replace a new value
My Field value inside InvGSTSummary :
Value 1:
"- 0%,19291.76,0.00"
"SE 0%,1068.39,0.00"
"ST 6%,2000.00,120.00"
The order of the Text List might change everytime,
Value 2:
"SE 0%,1068.39,0.00"
"- 0%,19291.76,0.00"
"ST 6%,2000.00,120.00"
Sample formula i write for testing as below :
InvGSTSumCode = #Word(InvGSTSummary; ","; 1)
The question is May i know how to take the First 2 character is "SE" to
amend the last 3 value become by (using 1068.39 * 6%=64.1034), than
replace the last 3 value become 64.1034
Final Result For the value should be :
"- 0%,19291.76,0.00"
"SE 0%,1068.39,64.10"
"ST 6%,2000.00,120.00"
New Update item: on 08/07/2019
Sorry may be my question not clear. Actually what i want to ask is possible to Loop over the a "field" [text list] for condition (if found "SE") value than just redo other calculation on the page.
New Update item: on 10/07/2019
Formula to extract the orignal value and replace value
FullSummary := #Trim(#Replace("SE" + #Right(InvGSTSummary; "SE"); "SE"; ""));
STCode := #Word(FullSummary; ","; 1);
Price := #Word(FullSummary; ","; 2);
SST:=#TextToNumber(Price) * 0.06;
CompVal:= STCode +","+Price+","+#Text(SST; "F2");
CompVal
Result of the formula:
Get field's entry you want to change,
Calculate entry's new value,
Replace entry in field.
Example for replacing entry that starts with "SE":
_entryOld := #Trim(#Replace("SE" + #Right(InvGSTSummary; "SE"); "SE"; ""));
_entryNew := #Word(_entryOld; ","; 1) + ... calculate your new value based on _entryOld;
#Replace(InvGSTSummary; _entryOld, _entryNew);
Here is an alternative for the "loop" to get the entry with "SE":
_entryOld := #Trim(#Transform(InvGSTSummary; "entry";
#If(#Contains(entry; "SE"); entry; "")));
Update to your updated question:
Use #Replace in last code line to replace the old entry (FullSummary) with the new value (CompVal):
FullSummary := #Trim(#Replace("SE" + #Right(InvGSTSummary; "SE"); "SE"; ""));
STCode := #Word(FullSummary; ","; 1);
Price := #Word(FullSummary; ","; 2);
SST:=#TextToNumber(Price) * 0.06;
CompVal:= STCode +","+Price+","+#Text(SST; "F2");
#Replace(InvGSTSummary; FullSummary, CompVal);
Related
I'm trying to return all values stored in the tNames variable.
Values exists in the field. The show multivalues as separate entries have been selected already but none of the names is returned.
Below is the sample code:
tNames := "";
#For(n := 0; n <= QuestionCount - 1; n := n + 1;
tNames := tNames + ", " + #Implode(#GetField("ChecklistContact_" +
#Text(n));",")
);
#Trim(tNames)
I dont know why its not returning anything, will appreciate your help.
The below returns only the contact with index 0, but I want to return all contacts in each document.
tCount := 0;
#For(n := 0; n <= QuestionCount - 1; n := n + 1;
tCount := tCount + #If(#GetField("ChecklistContact_" + #Text(n)) = ""; 0; 1)
);
#GetField("ChecklistContact_" + #Text(tCount))
Following comments from Richard the below return the required values, but will prefer not to hard code field name.
Is there any way of using for loop to return field names and values?
tNames := "";
tNames:= #GetField("ChecklistContact_1") : #GetField("ChecklistContact_2") : ... #GetField("ChecklistContact_7");
#Trim(tNames)
I don't believe that IBM's documentation says this explicitly, but I don't think #GetField works in column value formulas. The doc says that it works in the "current document", and there is no current document when the formula is executing in a view.
Assuming you know what the maximum number for N is, the way to do this is with a simple list:
ChecklistContact_1 : ChecklistContact_2 : ChecklistContact_3 : ... : ChecklistContact_N
If N is large, this will be a lot of typing, but you'll only have to do it once and copying and pasting and editing the numbers will make it go pretty quickly.
It might sound inelegant but, if you can, create a new computed field with your column formula in your form and then use that new field in your column. Also, from a performance standpoint you will be better off.
Maybe use your loop to create the list of fieldnames as Richard suggested, then display tNames
I have tried several times to enter a date range into the Search in view.
The search string i put into Search in view is as follow.
compositeData.Operasjon = "ST-MOD"
" FIELD OprPlanGruppe_1 = " + compositeData.Operasjon + " AND FIELD OprDato_1 = " +
dates.substring(0, dates.length() - 1);
The result is that only the last key value pair (FIELD OprDato_1 = 11.02.2014) is used to filter
The hole code is below:
var idag:java.util.Date = new java.util.Date();
var cal:java.util.Calendar =java.util.Calendar.getInstance();
var dateFormat:java.text.SimpleDateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy");
cal.set(java.util.Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
cal.clear(java.util.Calendar.MINUTE);
cal.clear(java.util.Calendar.SECOND);
cal.clear(java.util.Calendar.MILLISECOND);
var dates = "";
var i;
for(i = 0; i < 7; i++){
cal.set(java.util.Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek() + i);
dates += dateFormat.format(cal.getTime()) + ",";
}
dates = dates.replace("undefined", "");
return " field OprPlanGruppe_1 = " + compositeData.Operasjon + " AND FIELD OprDato_1 = " + dates.substring(0, dates.length() - 1);
Is there any possibilities to add more than one value after Field in the filter query?
Ex: FIELD OprDato1 = 10.02.2014,11.02.2014
You want to show all documents in view which have in field "OprDato_1" a date that is within the current week. You use the "Search in view results" property of xp:viewPanel. It uses full text search and has to have the syntax of full text search. You can compare dates with ">=" and "<=". So, an easy way to look for dates in a certain date range is
FIELD OprDato_1 >= 10.02.2014 AND FIELD OprDato_1 <= 16.02.2014
or shorter as
[OprDato_1] >= 10.02.2014 AND [OprDato_1] <= 16.02.2014
Your code for calculating the search string would look like this:
var cal:java.util.Calendar =java.util.Calendar.getInstance();
var dateFormat:java.text.SimpleDateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy");
cal.set(java.util.Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
var firstDate = dateFormat.format(cal.getTime());
cal.set(java.util.Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek() + 6);
var lastDate = dateFormat.format(cal.getTime());
return "FIELD OprPlanGruppe_1 = " + compositeData.Operasjon +
" AND FIELD OprDato_1 >= " + firstDate +
" AND FIELD OprDato_1 <= " + lastDate
This code calculates the date range for current week. You are free to set cal to any other date and date range would then be the week of this date.
This is my code
for (int m=0; m < i ; m++){
ta1.setText( s[m].getName().toString() + ", " + s[m].getProgramName().toString() + ", " + s[m].getUni1() + ", " + s[m].getUni2() + ", " + s[m].getUni3() + ", " );
}
It's supposed to print a line from an array of student ( called s) into a JTextArea ( called ta1 ). the problem is that it always only prints the last student in the array.
I need to print each student in a new line. could anyone help me sort it out?
When you set text on an element, the current position in the loop will take over the last one.
Try doing this.
String s = "";
for(int m = 0, m <i; m++){
s += s[m].getName.toString() + ", " + s[m].getprogramName().toString() + "\n;
}
ta1.setText(s);
Create a string and add each entry to it then add new line to end of each entry "\n"
Then do.
ta1.setText(s);
setText overwrites whatever is the current text.
You need append instead; you also need a "\n" at the end of a line.
I have some cases in my code where I am building a large string of text, such as a complex SQL statement. I intend to put this text together many times in a row, each with some slightly different parameters. I've come to the habit of using a subroutine named just procedure A(const S: String); which simply appends the text (S) to the larger string Text := Text + S + #10 + #13;
I was wondering if this could hinder the performance as opposed to using traditional string concatenation? I am beginning to think the compiler optimizes something like this:
Text := 'some' + ' ' + 'text' + ' ' + 'and' + ' ' + 'such';
to
Text := 'some text and such';
Is this true? Does the compiler optimize this scenario? If so, I may decide to change everything to something like this:
Text := 'select something from sometable st'+#10+#13+
'join someothertable sot on sot.id = st.sotid'+#10+#13+
'where sot.somevalue = 1'+#10+#13+
'order by sot.sorting';
Would this be faster theoretically than
Text:= Text + 'select something from sometable st'+#10+#13;
Text:= Text + 'join someothertable sot on sot.id = st.sotid'+#10+#13;
Text:= Text + 'where sot.somevalue = 1'+#10+#13;
Text:= Text + 'order by sot.sorting';
or how I usually do it:
A('select something from sometable st');
A('join someothertable sot on sot.id = st.sotid');
A('where sot.somevalue = 1');
A('order by sot.sorting');
An expression like
'a' + 'b'
is evaluated at compile time. Which means that an assignment
str := 'a' + 'b';
results in identical compiled code to
str := 'ab';
On the other hand, for
str := 'a';
str := str + 'b';
the concatenation is performed at runtime.
Note that putting all concatenations in one expression is still more efficient when non-constant expressions are used.
Consider this code:
A := '*';
B := 'person';
C := 'first_name=''Jerry''';
Q := 'select ';
Q := Q + A;
Q := Q + ' from ';
Q := Q + B;
Q := Q + ' where ';
Q := Q + C;
The six statements above will perform 5 separate concatenations.
Whereas:
Q := 'select ' + A + ' from ' + B + ' where ' + C;
will perform a single concatenation. Delphi will allocate the necessary space for the result and copy each of the six values into that space.
I am trying to update an element in a list with Lotus Formula.
I thought you would do it like this:
x := "0":"0":"0";
x[1] := "1";
But when I try to save I get the following error:
:= must be immediately preceded by a field or variable name
From the Lotus Domino Designer 7 Help:
The subscript operator cannot be used
on the left side of an assignment
statement. That is, you cannot assign
a value to a subscripted element. You
must build the complete list and then
assign it. For example, if Categories
is a 3-element list and you want to
assign a new value to element 2:
FIELD Categories := Categories[1] : "CatNew" : Categories[3]
You can usually get by using #Implode, #Explode, or #Replace. But if you really need it you can do this:
REM {FieldName[Index] := NewVal};
Index := 2;
NewVal := "CatNew";
maxIndex := #Elements(FieldName);
PrePart := #If(Index > 1; #Subset(FieldName; Index-1); "");
PostPart := #If(Index < maxIndex; #Subset(FieldName; (Index-maxIndex)); "");
Field FieldName := PrePart : NewVal : PostPart