Change kotlin val in debugger - android-studio

How change val property (not method variable) in debugger?
Yes, I know that val is final analog
Breakpoint here:
Set value disabled in context menu:
Evaluate not work:

In the debugger select the value use the context menue on right click to select "set Value..." (default shortcut F2). The value of the variable should now be displayed in a text field. Enter the desired value and press enter to change the value. You only need to enter the value not an assignment (e.g. x = "test" is wrong, just enter the value "test"). The changed value is now applied to the field.
In the debugger it IS also possible to change values on immutable val defined values in Kotlin as it is also possible to change the value on final defined variables in Java.

I was able to modify val value on the fly using "evaluate and log".
Check full answer

You can do it using reflection.
Just open the Evaluate Expression menu, then type:
val field = Main::class.java.getDeclaredField("b")
field.isAccessible = true
field.set(b, true)

Related

Using custom table to feed drop-down list datasource

Let's assume that I have Custom Table named Possible URL target parameters with code name xyz.PossibleTargets with 2 columns:
Explanation and Value.
How to feed drop-down field on page type with data to have Value (from table) as Value and Explanation as name in drop-down?
What I already tried and it is not working:
Generate value;name pairs divided by newline and place it as List of options:
z = ""; foreach (x in CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items) {z += x.GetValue("Value"); z +=";"; z += x.GetValue("Explanation"); z += "\n" }; return z;
Validator do no allow me to do such trick.
Set option Macro expression and provide enumerable object:
CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items
In Item transformation: {%Explanation%} and in Value column {%TargetValue%}.
This do not work also.
Dropdown configuration
How to do this correctly? Documentation and hints on the fields are not helpful.
Kentico v11.0.26
I think that you should do it without marking field as a macro. Just type there the macro. Take a look on screen
No need to use a macro, use straight SQL, using a macro only complicates what appears to be a simple dropdown list.
SELECT '', '-- select one --' AS Explanation
UNION
SELECT TargetValue, Explanation
FROM xyz_PossibleTargets -- make sure to use the correct table name
ORDER BY ExplanationText
This should populate exactly what you're looking for without the complication of a macro.

Ampscript BuildRowsetFromString() fails on single item

I've been tasked with an ExactTarget task, which uses Ampscript. Trying to learn on the go here. See code snippet below:
%%[
Var #testString, #testOutput
Set #testString = Qwerty
Set #testOutput = BuildRowsetFromString(#testString,"~")
]%%
TestOutput:%%= v(#testOutput) =%%
The code works if the testString contains a ~, but when there is no ~ character in the string, the ouput is blank. Is this correct by design? Do I need to add a conditional to check for the presence of the ~ character?
That's the expected behavior. The BuildRowsetFromString() function alone isn't going to return any value when displayed, you're going to need to use Row() and Field() in order to pull the value out.
Using your example:
%%[
Var #testString, #testOutput
Set #testString = "Qwerty"
Set #testOutput = BuildRowsetFromString(#testString,"~")
]%%
RowCount: %%=RowCount(#testOutput)=%%
TestOutput: %%=v(#testOutput)=%%
The RowCount() function returns a value of 1, essentially saying it knows there's at least one 'row' in there. To display that one value, you'll need to wrap that value with Field() and Row():
TestOutput: %%=Field(Row(#testOutput,1),1)=%%
If you want to display other values in the string, say you were passing "Qwerty~Second~Third", you'll need to either change the number at the Row() function or perform a loop.
References
Using Loops
BuildRowsetFromString() Function

IBM Cognos prompt value when not entered

I have a problem in report studio. please help me to figure this out..
i have a optional prompt, i want to check whether the value is selected or not..
Please help how to check..
if (?parameter? is null ) then ('1') else ('2')
or
if (ParamDisplayValue('parameter') is null ) then ('1') else ('2')
Both the above are not working..
Suppose if i select any value in the prompt then the else part works and i get the result as 2, if i wont select anything then i'm not getting the result as 1
My guess, without doing extensive testing, is that an empty optional prompt doesn't exist at all and can't be compared to null. That said, I believe there's an easy fix.
Since you know that when you select an item '?parameter? is null' will return false, '?parameter? is not null' should return true and you can reverse the logic:
if (?parameter? is not null) then ('2') else ('1')
Try to put a conditional block. Set a block variable of type boolean with this expression:
ParamDisplayValue('myParam') is null
Then go to your conditional block again switch property "current block" to yes/no.
When yes (meaning that our block variable is true so the parameter is null) add a text item and just write "All".
When no add a text item with source type as report expression and write ParamDisplayValue('myParam')
P.S: there is also a way to count how many values the user selected (so as not to display all of them 1 by 1 but just show "62 values selected") but it needs some javascript and a hidden prompt field.
Use ParamCount
More details here:
http://joesanswers.blogspot.com.au/2008/09/checking-for-empty-parameters-in-cognos.html

Deleting contents of a string - TextBox behaves slightly differently from DataGridView text cell

If you set up a simple test form with a TextBox bound to a string property of a class and delete the content the value passed back to the property setter is "".
If you do the same thing with a cell in a DataGridView the value passed back to the property setter is Nothing.
Why the difference and is there anything we can apply to the DataGridView to make it behave the same as a TextBox?
if am correct the DataGridViewTextBoxCell by default is Null and the TextBox by Default is String.Empty
you might check the Null vs Empty
Nothing is VB's version of C#'s null or a database's NULL. It means that there is no value, as opposed to "" which means that there is a value, of an empty string.
I'm not entirely sure, but I suspect the difference is because a textbox's Text property is always a string, but a cell's Value property can be any object. You can use the null-coalescing operator to return an empty string when the value is Nothing.
Set(ByVal value As String)
_Surname = If(value, "")
End Set
Alternatively, you can validate the cell post-edit and set it to ""explicitly. see here for an example - instead of messaging the user, you'd just change the value.
DataGridView converts "" into Null during cell parsing.
If you handle CellParsing event and just set ParsingApplied, then no further parsing will be performed and the resulting value will remain "".

computed field value in xpages

I am trying to update a computed fields value on click of a button with a value of a edit box + its own value.
Code written on button: here i put value of edit box in scope variable and make edit box blank. comment_te is the name of edit box
requestScope.put("commentValue", getComponent("comments_te").getValue);
getComponent("comments_te").setValue("");
Code written for value of computed field: comments is the name of computed field
getComponent("comments").getValue + "\n" + requestScope.get("commentValue")
But I get the output is:
0 com.ibm.xsp.component.xp.XspInputText#65426542
Please help me with this.
You're missing the parentheses in your calls to getValue(). By omitting these, you're returning a pointer to the getValue method of the component, not the result of invoking that method. Change each reference to getValue to getValue(), and you'll get a different result.
Your code returning the Object.
Try the following.
This following code get the the editbox value and set to a scope variable.
requestScope.commentValue = getComponent("comments_te").value;
getComponent("comments_te").value = "";
This following code sets the value to the computed field.
getComponent("comments").value = getComponent("comments").value + "\n" + requestScope.commentValue;
When you are appending the value to the computed field, as default it will add 0 to its value. Do the validation if you want.
I hope this helps you...!!!

Resources