Tkd widget not finding row and column options - d

I am trying to create a simple GUI application using tkd package and following code:
// modified from: https://github.com/nomad-software/tkd
import tkd.tkdapplication;
class Application : TkdApplication {
auto labellist = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", ];
override protected void initInterface() {
int ncol =0;
auto frame = new Frame(2, ReliefStyle.groove);
frame.pack(10);
foreach(lab; labellist){
auto label = new Label(frame, lab);
label.grid(row=nrow, column=0);
auto entry = new Entry(frame);
entry.grid(row=nrow, column=1);
nrow += 1;
}
auto exitButton = new Button(frame, "Exit").setCommand(&this.exitCommand).pack(10);
}
private void exitCommand(CommandArgs args) {
this.exit();
}
}
void main(string[] args){
auto app = new Application();
app.run();
}
However, it is giving following error:
$ dub run
Performing "debug" build using /usr/bin/dmd for x86_64.
x11 1.0.21: target for configuration "tcltk-import" is up to date.
tcltk 8.6.5: target for configuration "library" is up to date.
tkd 1.1.12: target for configuration "library" is up to date.
tkdgui ~master: building configuration "application"...
source/app.d(15,15): Error: undefined identifier row
source/app.d(15,25): Error: undefined identifier column
source/app.d(17,15): Error: undefined identifier row
source/app.d(17,25): Error: undefined identifier column
source/app.d(18,4): Error: undefined identifier nrow
/usr/bin/dmd failed with exit code 1.
Details about grid are mentioned here. Row and column are valid options to be entered.
Where is the problem and how can it be solved.

There are two issues in your code. Here's the first:
label.grid(row=nrow, column=0);
^^^^ ^^^^^^^
D does not support named parameters, which you're attempting to use. Instead you will need to use positional parameters:
label.grid(0, nrow);
FWIW, there are some proposals to add named parameters to D, but none are in the language as of now.
The second issue is nrow is not defined anywhere. Judging by the existence of ncol and the fact it's used nowhere, it seems you changed the code from dealing with columns to dealing with rows and did not change the name of ncol to nrow.

Related

Using decision within a java delegate

I am trying to evaluate a decision inside a camunda java delegate that I created. Following is the code that I am using. Upon executing the delegate( which runs fine without the DMN part), I get an error stating:
java.lang.NoClassDefFoundError: de/odysseus/el/util/SimpleContext"
I am using gradle and have added the following to my .build :
compile 'org.camunda.bpm.dmn:camunda-engine-dmn' ,
'org.camunda.bpm.dmn:camunda-engine-feel-juel:7.5.0-alpha2' ,
'de.odysseus.juel:juel-spi:2.2.7',
'de.odysseus.juel:juel-api:2.2.7' ,
'de.odysseus.juel:juel-impl:2.2.7'
Any suggestion how can I fix this error up? Thanks.
DMN Code:
DmnEngine dmnEngine = DmnEngineConfiguration.createDefaultDmnEngineConfiguration().buildEngine();
// read the DMN XML file as input stream
InputStream inputStream = CheckDatafileExistsExecutor.class.getResourceAsStream("decision1.xml");
// parse the DMN decision from the input stream
DmnDecision decision = dmnEngine.parseDecision("Decision_13nychf", inputStream);
//accessing the input variables
VariableMap variables = Variables.fromMap((Map<String, Object>) decision);
// evaluate the decision table with the input variables
DmnDecisionTableResult result = dmnEngine.evaluateDecisionTable(decision, variables);
int size = result.size();
DmnDecisionRuleResult ruleResult = result.get(0);
Remove all your dependencies and add only compile group: 'org.camunda.bpm.dmn', name: 'camunda-engine-dmn', version: '7.6.0'
You can try also menskis example, but change the camunda-engine-dmn to 7.6.0
and
DmnDecisionTableResult results = dmnEngine.evaluateDecisionTable("decision", "Example.dmn", variables);
to
InputStream fileAsStream = IoUtil.fileAsStream("Example.dmn");
DmnDecisionTableResult results = dmnEngine.evaluateDecisionTable("decision", fileAsStream, variables);
You can use delegate service for decision evaluation based on key or Id,
eg:-
public void execute(DelegateExecution delegateExecution) throws Exception{
DecisionService decisionService = delegateExecution.getProcessEngineServices().getDecisionService();
decisionService.evaluateDecisionByKey(dmnToInvoke).variables(delegateExecution.get Variables()).evaluate();
}

Record with List of Records Unit Test Failing

I have the following records:
namespace FunctionalInnovate.Domain
module Voting=
open System
type Vote = {
VoteId : int
SuggestionId : int
VotePreference : int
}
type Suggestion = {
SuggetionId : int
SuggestionText : string
}
type User = {
UserId : int
Votes : Vote list
}
From these records, I have created the following Unit Test:
module ``Voting Tests``
open NUnit.Framework
open FsUnit
open FunctionalInnovate.Domain.Voting
[<Test>]
let``Get Vote from given SuggestionId``()=
let votePreference = 1
let vote1 = { VoteId = 1; SuggestionId = 34; VotePreference = votePreference }
let vote2 = { VoteId = 2; SuggestionId = 654; VotePreference = votePreference}
let votes = [ vote1; vote2; ]
let user = {UserId = 321; Votes = votes}
Assert.IsTrue(true) |> ignore
I've just changed the Assert statement to something simple at this point as it keeps failing at present. Using ReSharper, when I run the test I get an error. Upon investigation, it appears to be a problem with the List of Votes being assigned to the Votes type within my user declaration. What I find strange though is that if I load all of the types into FSI and then load each line of the test in turn, it works without any errors.
Anyone got any ideas as to why the unit test is failing?
The error ReSharper Test Runner is producing is:
System.MissingMethodException : Method not found: 'Void User..ctor(Int32, Microsoft.FSharp.Collections.FSharpList`1<Vote>)'.
at Voting Tests.Get Vote from given SuggestionId()
As per #Tomas Petricek and #John Palmer's advice, it was an issue with my ''FSharp.Core.dll'' version.
The version of this DLL in my UnitTest project was much older than what was in my Domain project.
All I did to fix it was going into NuGet Package Manager and update that specific package. Upon running my tests again, everything was green and healthy.

How do I create a loop in omnet++?

How do I create a loop in omnet ++ with a user defined variable.
I tried the following but it gave me an error:
network Network{
parameters:
int n #prompt("enter number") = default(2);
connections:
for i=0..n do { // here the n gives me a syntax error (unexpected NAME, expected {
//do things
}
Have a look at the OMNeT++ manual. The for syntax is without do, e.g.
for i = 0..count-2 {
node[i].port[1] <--> node[i+1].port[0];
}

How to add a List to HBox in JavaFX?

Am trying to read some values from database and display it in a List.
list = new List();
list.setSize(30, 280);
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager
.getConnection("jdbc:mysql://localhost:3306/project?"
+ "user=root&password=virus");
statement = connect.createStatement();
preparedStatement = connect
.prepareStatement("select subname from subject");
rs=preparedStatement.executeQuery();
while (rs.next()) {
subject = rs.getString("subname");
list.add(subject);
}
}
The import statement for List is-
import java.awt.List;
So I think List control is not available in JavaFX.
I tried to place the List in HBox -
hb.getChildren().addAll(addSubName, list, b2);
Then I got an error -
method addAll in interface ObservableList<E> cannot be applied to given types;
required: Node[]
found: TextField,List,Button
reason: varargs mismatch; List cannot be converted to Node
where E is a type-variable:
E extends Object declared in interface ObservableList
Is this error correctable ? If not, tell me about a control that can be used as a substitute for List in JavaFX.

problems with writing rows to a DataSet in Visual Studio 2010 C++

I am new to Visual Studio 2010 and there seen very few C++ examples of anything on MSDN so would appreciate some help.
I have used the DataSet function from the ToolBox window to create a single table with three columns (for brevity I have left out two of them in the example below.
I am getting the following error:
error C3293: 'Item': use 'default' to access the default property (indexer) for class 'System::Data::DataRow'
Here is the code as generated by VS2010 instantiating the table:
this->GraphInput->DataSetName = L"GraphDataIn";
this->GraphInput->Tables->AddRange(gcnew cli::array< System::Data::DataTable^ >(1) {this->RefElectInput});
//RefElectInput
this->RefElectInput->Columns->AddRange(gcnew cli::array< System::Data::DataColumn^ >(3) {this->RefElect0Av, this->RefElect0Max, this->RefElect0Min});
this->RefElectInput->MinimumCapacity = 7;
this->RefElectInput->TableName = L"RefElecInput";
//
// RefElect0Av
//
this->RefElect0Av->ColumnName = L"RefElect0Av";
this->RefElect0Av->DataType = System::Double::typeid;
Here is the code where I try towrite to the row (I have only shown one column):
DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->Item[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];
//the error data is of type doubleoccurs here.
//other column's removed.
RefElectInput->Rows->Add(myRow);
I would be grateful for your assistance.
Thank you Simon
Have you tried:
DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->default[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];