Error: "Cannot find 'get' method for string class." - string

I'm coding with GUIDE. I want to get data input from handles.edit1,...handles.edit8 and save to variable handles.in(1,1),...handles.in(1,8). My code is below and I get an error:
Cannot find 'get' method for string class.
edit = ["handles.edit1","handles.edit2","handles.edit3","hanles.edit4","handles.edit5","handles.edit6","handles.edit7","handles.edit8"]
for i = 1:1:8
handles.in(1,i) = str2num(get(edit(1,i),'string'));
end

you should change
edit = ["handles.edit1","handles.edit2","handles.edit3","hanles.edit4","handles.edit5","handles.edit6","handles.edit7","handles.edit8"]
to
edit = [handles.edit1,handles.edit2,handles.edit3,hanles.edit4,handles.edit5,handles.edit6,handles.edit7,handles.edit8];

Related

how to define a list of variable number of objects in groovy?

I am learning groovy, I am using the documentation and some youtube videos. I want for testing to find out how to declare an array of objects, but that array will have a x number of objects depending on some stuff. Here is what I tried:
class Issue {
String type = ""
String severity = ""
String linestart = ""
String filename = ""
String meesage = ""
}
def test(){
Issue[] Issues = new Issue[5]
Issues[0].type = "error"
println Issues[0].type
}
test()
what I get:
Caught: java.lang.NullPointerException: Cannot set property 'type' on null object
java.lang.NullPointerException: Cannot set property 'type' on null object
I assume my array does not have 5 Issues objects inside, and that is why is trying to set on null object. How would be the right syntax to do so?
You are right- all the values are initially null. You have to first create instances of Issue and assign it to the array elements,
Issues[0] = new Issue()
Issues[0].type = "error"
alternatively, using "groovy" syntax,
Issues[0] = new Issue(type: "error")

Type Mismatch - Lotusscript

I don't know where I'm wrong but I kept on getting "Type mismatch" error
Here is the original code
Dim policy As New Policy
Dim policyDocument As NotesDocument
Set policyDocument = p_baseManager.base_policyDocument
policy.formName = policyDocument.Getitemvalue("Form")(0) //Had type mismatch error on this line
policy.universalId = policyDocument.Universalid
policy.formX = policyDocument.Getitemvalue("FormX")(0)
I tried to modify it a bit to display some of the values
Dim policy As New Policy
Dim policyDocument As NotesDocument
Set policyDocument = p_baseManager.base_policyDocument
Print "universal id = " + policyDocument.Universalid
Print "FORM NAME = " + policy.formName
policy.formName = "FormName"
Print "FORM NAME = " + policy.formName
policy.formName = policyDocument.Getitemvalue("Form")(0) // still getting type mismatch
policy.universalId = policyDocument.Universalid
policy.formX = policyDocument.Getitemvalue("FormX")(0)
Thank you!
Adding error handling is the best way to find out where the error is occurring. The type mismatch will be data-specific, so it's going to be difficult to troubleshoot without having access to the environment. The best library for error handling in LotusScript is beyond all doubt OpenLog.
Ok, lets analyze this using your "DEBUG"- Code. We have two custom classes that we know nothing about:
Class name: Policy
Instance: policy
and
Class name: ???
Instance: p_baseManager
Then we have the line that throws the error:
policy.formName = policyDocument.Getitemvalue("Form")(0)
From your Test- Line
policy.formName = "FormName"
we know, that policy.formName accepts a String as an input and that the left side of our erroneous line does throw an error in itself.
Now, if we have a "Type mismatch" that means that our right part of the assignment does not return a string.
If p_baseManager.base_policyDocument did not return a valid NotesDocument, then we would get an Object variable not set in that line --> We can conclude, that policyDocument is a valid NotesDocument and not Nothing.
Now lets look at GetItemValue("Form"): It returns an Empty String, if the document does not contain an item named "Form": An empty String still is a String --> No Type Mismatch in that case.
The only possibility, that policyDocument.Getitemvalue("Form")(0) does not return a String, is, if the item is present but contains a number or a date value...
So: What to do now?
First of all: Are you SURE that the error is in that line (did you use Debugger)?
Second: Use the debugger to find out the value of the Form- Item of your PolicyDocument
Third: As mentioned by Paul Stephen Withers: Use error handling to EXACTLY identify the error line, error code and error.

Node.js - Pass Session Variables to a SQL Server function call

In a MS Teams BOT I have working dialog code to ask a series of questions and return the formatted response back to the user in a session like so:
session.send(`Details: <br/>Question1: ${session.dialogData.Question1} <br/>Question2: ${session.dialogData.Question2} <br/>Question3: ${session.dialogData.Question3}`);
So I know the values I need are in the session variables. Now I want to pass the session variables to an SQL insert function (executeStatement):
var session_username = session.dialogData.username
var session_yesterday = session.dialogData.yesterday
var session_today = session.dialogData.today
var session_obstacles = session.dialogData.obstacles
executeStatement(session_username, session_yesterday, session_today, session_obstacles)
I can pass strings and the function works fine. But when I try to pass the session variables like above or just passing session.dialogData.yesterday for instance, straight into the function all of the code runs fine - no errors are thrown - but the session variables are not inserted and 0 rows are returned.
What is the proper way to pass a session variable? Google has not been kind in this regard. :)
Thank you in advance...
Edit:
So I couldn't sleep and had a (weird) idea. Use the session.send when assigning the values to the variable like so:
session_username = session.send(`${session.dialogData.username}`)
or
session_username = session.send(session.dialogData.username)
It writes to the database but it is an [object Object] value. So how do I get to the actual value? Hmmm...Still looking
Edit 2:
To get at the object value I tried:
session_yesterday = session.dialogData.yesterday.text()
and
session_yesterday = session.dialogData.yesterday.value()
For the 1st attempt, .text() I received the following error:
TypeError: Cannot read property 'text' of undefined
at Array.<anonymous> (C:\Developer\dailyStatus\index.js:96:56)
at C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\WaterfallDialog.js:67:39
at next (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\WaterfallDialog.js:92:21)
at WaterfallDialog.beforeStep (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\WaterfallDialog.js:99:9)
at WaterfallDialog.doStep (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\WaterfallDialog.js:61:14)
at WaterfallDialog.dialogResumed (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\WaterfallDialog.js:46:14)
at Session.endDialogWithResult (C:\Developer\dailyStatus\node_modules\botbuilder\lib\Session.js:358:28)
at PromptText.Prompt.invokeIntent (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\Prompt.js:331:21)
at PromptText.Prompt.replyReceived (C:\Developer\dailyStatus\node_modules\botbuilder\lib\dialogs\Prompt.js:147:18)
at Session.routeToActiveDialog (C:\Developer\dailyStatus\node_modules\botbuilder\lib\Session.js:525:24)
/ - ERROR: Cannot read property 'text' of undefined
/ - Session.endConversation()
I was stubbornly trying to access the variables because I KNEW that the information was there.
I tested going back up into the dialog results.response like below and it worked:
session.dialogData.yesterday = session_yesterday = results.response;
It honestly is still a little odd to me that I couldn't just access the variable directly but oh well - lesson learned I guess.
Thank you

eval() is not working properly

I get the following error while trying to evaluate a predicate in a a4solution:
Fatal error in /some/path at line 9 column 2: Field "field
(A/Attribute <: type)" is not bound to a legal value during
translation.
Here is the code at the origin of the error:
for(ExprVar a : solution.getAllAtoms()){
// additional checks are here to assure that a is of an "appropriate type"
solution.eval(predicate.call(a));
}
In my vain attempts to solve this problem by myself, I read from this source http://code.google.com/p/alloy4eclipse/issues/detail?id=86 that the way the solution has been read from the file might cause this problem.
But the source doesn't give further details.
I have created my solution object as follows :
XMLNode xml = new XMLNode(new StringReader(source.getFileContent()));
this.solution = A4SolutionReader.read(new ArrayList<Sig>(), xml);
Thank you for your support
The problem was that the expression to be evaluated (predicate.call(a)) was drawn from one CompModule object (namely the predicate function was taken from there) while the solution object, against which the expression was evaluated, was not obtained from the same CompModule, but was read from a file.
Generally, when reading a solution from an xml file, to be on the safe side, it is recommended to reread and reconstruct everything from that xml file, e.g.,
XMLNode xmlNode = new XMLNode(new File("my_solution.xml"));
String alloySourceFilename = xmlNode.iterator().next().getAttribute("filename");
Module module = CompUtil.parseEverything_fromFile(rep, null, alloySourceFilename);
A4Solution ans = A4SolutionReader.read(module.getAllReachableSigs(), xmlNode);
In some cases it suffices to just pass the sigs from the original CompModule to the reconstructed solution:
XMLNode xmlNode = new XMLNode(new File("my_solution.xml"));
A4Solution ans = A4SolutionReader.read(originalModule.getAllReachableSigs(), xmlNode);

C#/ Html Agility pack error "Value cannot be null. Parameter name: Source."

I've used html agility pack before, and have had good results with a little bit of trial and error. I'm currently trying to use it to return a node set with an xpath I get by right- clicking "Copy XPath" in Firefox. I've done some searching, and I see that the browser will often add "tbody" for table tags. I tried it with removing this with no luck. Here is the xpath given to me by Firefox:
/html/body/p[3]/table/tbody/tr/td/table/tbody/tr[3]
Using it as- is throws the error: "Value cannot be null. Parameter name: source."
This occurs on line:
nodeList = htmlDoc.DocumentNode.SelectNodes("/html/body/p[3]/table/tbody/tr/td/table/tbody/tr[3]").ToList();
I'll continue to read, in the meantime if this is an easy fix to anyone, I'd appreciate a tip.
Update: This is the actual code:
protected override List<IDataPoint> ReturnDataPointsFromIndividualAddressString(string AddressString)
{
List<IDataPoint> earningsAnnouncements = new List<IDataPoint>(); //Not used, yet..
HtmlWeb hwObject = new HtmlWeb();
HtmlDocument htmlDoc = hwObject.Load(AddressString);
if (htmlDoc.DocumentNode != null)
{
List<HtmlNode> nodeList = new List<HtmlNode>();
nodeList = htmlDoc.DocumentNode.SelectNodes("/html/body/p[3]/table/tbody/tr/td/table/tbody/tr[3]").ToList();
}
}
It seems this error occurs on this line:
nodeList = htmlDoc.DocumentNode.SelectNodes("/html/body/p[3]/table/tbody/tr/td/table/tbody/tr[3]").ToList();
The thing is, if SelectNodes method doesn't find nodes by xpath expression passed it returns null. You could find more information in this answer to a similar question HTML Agility Pack Null Reference. And then you call a ToList() method on a null object which is actually causes an NullReferenceException.
To avoid this check the this variable against null like this:
var nodes = htmlDoc.DocumentNode.SelectNodes(...);
if (nodes != null)
{
nodeList = nodes.ToList();
}

Resources