Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I copied code from here but I'm getting an error when trying to run the code.
The problem would be in:
Public NextItem As New queueItem
and the error message is:
user-defined type not defined
Is my VBA version not right to do this or am I doing something wrong?
You probably mean this link? The one you provided has the alternative implementation (with arrays, not with references).
I got it to work for me. Steps:
Right click on the VBA project file name, and go to Insert-> Class Module:
Click F4. The Properties window appears. Then go to the class Name and change it to Queue:
Copy and Paste the Queue Class code you found at the web site. Repeat the previous and this step for the QueueItem class (i.e., insert a Class Module, name it QueueItem and copy the code inside that class module).
This time, insert a Module using the same process (not a Class Module, but rather a simple Module). You do not need to give your module a name, Module1 will be OK.
Copy the Sub TestQueue() inside the module and run it. It should work. If you use Option Explicit on your module, you will get an error that element is undefined. So we need to define it: Dim element as Variant, under the first few Dim statements of the subroutine. Then it should run.
The above worked for me, let me know if I can be more precise, or send the file to you.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 29 days ago.
Improve this question
I've inherited a Perl Catalyst application that I'm trying to port to a new server. The application uses FormFu with the HTML::FormFu::Model::DBIC module used to load data from a result set.
I have a DBIx table, say MyTable, with an auto-generated Result implementation and a custom ResultSet implementation. In the custom ResultSet implementation there are some subroutines, e.g. sub my_sub, that return filtered subsets of data.
In a FormFu YAML file, the following will fetch all the records from MyTable:
elements:
- type: Select
model_config:
resultset: MyTable
This is equivalent to fetching, in a Controller, $schema->resultset('MyTable'). This executes correctly on both the old server and the new server.
On the old server, I can use dot notation to call the subroutine to fetch the subset of records it returns like so:
elements:
- type: Select
model_config:
resultset: MyTable.my_sub
This is equivalent to fetching in a Controller, $schema->resultset('MyTable')->my_sub. This executes correctly on the old server. On the new server, in FormFu, this throws the error:
Can't find source for MyTable.my_sub at /[...]/HTML/FormFu/Model/DBIC.pm
I've added debugging to the FormFu DBIC.pm module to see if it's doing anything special. The code it calls is $schema->resultset($rs_name); where rs_name is the name given in the resultset parameter, "MyTable.my_sub", and $schema is of type Moose::Meta::Class::__ANON__::SERIAL, which I assume is some kind of wrapper. Within a Catalyst controller, a schema is of type myapp::Schema.
What am I missing? Is there some configuration option I need to set? Some module I need to install? I can't find any documentation or examples that show a FormFu resultset with dot notation, yet on the old server it works.
When I attempted to add logging to the working DBIC.pm file, I discovered that the developer from whom I inherited this application symlinked the module's DBIC.pm file to a custom DBIC.pm file in his own home folder with the extended functionality.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am trying to automate the following tasks in Enterprise Architect:
Add new tagged Value types
2. Make certain changes to DDL Templates (e.g add system versioning to a table by replacing the DDL Create Table Template for MySQL with another template, that contains a "With System Versioning" clause)
Is there a way to achieve this via scripting (https://sparxsystems.com/enterprise_architect_user_guide/15.0/automation/automation_interface.html), by writing an Add In (https://sparxsystems.com/enterprise_architect_user_guide/15.1/automation/addins_2.html) or by using MDG Technologies (https://sparxsystems.com.au/enterprise_architect_user_guide/14.0/modeling_tools/mdgtechnologies_2.html) for Enterprise Architect?
Thank you in advance for all comments, answers and ideas!
Adding tagged value types is definitely possible.
I use this code in my Model wrapper
This is C#, but the translation to any other supported language such as VBScript is trivial.
public void addTaggedValueType(string tagName, string tagDescription, string tagDetail)
{
global::EA.PropertyType taggedValueType = (global::EA.PropertyType)this.wrappedModel.PropertyTypes.AddNew(tagName, "");
taggedValueType.Description = tagDescription;
taggedValueType.Detail = tagDetail;
taggedValueType.Update();
}
I don't think the API has a feature to update DDL templates directly, but you can deploy those with an MDG.
And you can include an MDG into your add-in. See this add-in class for an example
Normally tagged value types are also distributed in an MDG and not created directly by an add-in.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have seen many cases where we can create a Scala project with only Scala object file and have our code inside it without the need of having a Scala class file.
I am currently working in a project where the Developer has written the code in the Scala object file (which acts as an object) instead of writing in a class file. To be more precise here is the screen shot of my IDE which shows that the code is written in an object file.
I want to know significance of writing a code in a Scala class and object file. What is the ideal scenario to use them?
There is a similar post available here which shows only the difference between a class and an object however I want to know when should I consider to use a Scala class and when to use a Scala object?
Use class when you want to create the same data structure multiple times with difference values. For example, a class could represent a row of data in a database application, or a client request in a web server.
Use object when you only need a single copy of the data structure in your program. For example, the command line for a program, or a data cache.
Classes can have short lifetimes, so use them for data that comes and goes. Objects always last until the program completes, so use them for data that needs to be available permanently.
It is reasonably straightforward to convert an object into a class, so start with an object unless you know that you are going to need multiple instances of the data.
If you just want to group similar functions or data (in a namespace), put it in an object.
If you want are writing code for a software library, use classes that can be created and deleted as required.
Note that this applies to top-level objects. An object can also be used as a class member or as a local value, but in this case it operates like a class in that it can have multiple instances and may have a limited lifetime.
An object is something that you can only have one in your program. It's most of the time used to contain functions or objects that don't change much. It's the equivalent of static in other languages
For instance:
object StringUtils {
val LF = "\n"
def toUpperCase(str: String) = str.toUpperCase()
}
// usage
StringUtils.toUpperCase("foo")
On the other hand, a class is something you can create with new. You can have several instances of a class in your program
class StringContainer(str: String) {
def toUpperCase() = new StringContainer(str.toUppercase())
}
// usage
val myString = new StringContainer("foo")
myString.toUpperCase()
For more detailed examples you can look at the scala documentation:
https://docs.scala-lang.org/tour/classes.html
https://docs.scala-lang.org/tour/singleton-objects.html
https://docs.scala-lang.org/tour/case-classes.html
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am building a example project with sections using a TableView with this video:
https://www.youtube.com/watch?v=zFMSovtqqUc
When this boy explain exactly at 2 minutes and 55 seconds a list of the variables created in the struct should appear in the list, but it does not.
Can someone help me to understand what I am doing wrong?
Attached a print screen of my Xcode displaying the values where the list of value explained in the video should appear.
I am just a beginner following some video to learn to code.
Thank you very much for your time, I really appreciate it!
The same it's happening to me, look
If for you it's a big problem you can put 2 parenthesis around the value you are creating
This seems to fix the problem.
Conventions
Sorry but I could not avoid this
Objects is a wrong name for a struct (intact struct values are NOT objects)
Implicit unwrapped optionals (like the property of the struct into the example) are dangerous
Variable names should begin with a lowercase char
In Swift we don't put the name of the type of the variable inside the name of the variable.
The variables aren't recognised when there is a ] automatically provided when you type in [ like this:
If you delete the ] as soon as it appears when you type in [, the error is fixed, like so:
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
When i run my PMD plugin they say System.out.println has been used. why is System.out.println bad to use and is it a defect when using PMD plugin? and what is the alternative way of over coming this?
A logger can be turned ON/OFF using a configuration but System.out.println cannot be. Importantly loggers provide different levels of logging and again can be controlled through a configuration file.
Also using loggers you can configure rotation, purging etc but cannot do the same for sysout. This is useful especially in a production environment, executing a lot of code, and generating a lot of logging.
System.out.println() is considered bad practice for Logging.
Because of
No ability to turn it (ON/OFF)
No ability to set output levels (TRACE, DEBUG, INFO, WARN, ERROR),
without having to recompile your code
Another disadvantage is that the standard output of a program can be redirected, for instance and it's not always clear where the output is actually going, for instance if you do this:
java SomeClass > someFile
In this case the use of a logging API will help you.
But there are situations where you genuinely want to print something to the standard output too, for those occasions there is java.io.Console, which cannot be redirected, so if you're running a command line java program, it gives you confidence that the users are seeing the messages intended to them.
System.out.println..
are usually intended for debugging purposes and can remain in the
codebase even in production code. By using a logger one can
enable/disable this behaviour at will (and by priority) and avoid
clogging the Standard out log.
(from SourceMeter Java user guide under "Java Logging Rules")
Import needed (.jar)
Logger site
Example:
import org.apache.log4j.Logger;
class Foo{
private static final Logger LOG = Logger.getLogger(Foo.class);
public void testA () {
System.out.println("Entering test");
// Better use this
LOG.info("Entering test");
}
}
Printing excessive amounts of into to System.out can become a performance bottleneck because it is synchronized, code from PrintStream:
public void println(float x) {
synchronized (this) {
print(x);
newLine();
}
}
This is because, PMD defines a java logging rule named SystemPrintln which detects System.out.println in the code and consider as a defect.
Since: PMD 2.1
System.(out|err).print is used, consider using a logger.
This rule is defined by the following XPath expression:
//Name[
starts-with(#Image, 'System.out.print')
or
starts-with(#Image, 'System.err.print')
]
And you should be able to modify above XPath expression to override the behavior( I am not sure though)
Below link should give you more insight,
http://pmd.sourceforge.net/pmd-4.2.6/rules/logging-java.html