Programming

52K

Solutions

40K

Contributors

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

Share tech news, updates, or what's on your mind.

Sign up to Post

I could use some help with my script. I put *** where I need help making a code that would auto enter the most recent sundays date. Could you help?

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_

sub subSub1_()
   autECLSession.autECLOIA.WaitForAppAvailable
   
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[tab]"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "158"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[field+]"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "5"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[enter]"
   
   autECLSession.autECLPS.WaitForAttrib 10,56,"00","3c",3,10000

   autECLSession.autECLPS.WaitForCursor 10,57,10000

   autECLSession.autECLOIA.WaitForAppAvailable
   
   autECLSession.autECLOIA.WaitForInputReady
   ***Input the most recent sunday's date.
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[field+]"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[field+]"
   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "580171"
end sub
1
Big Business Goals? Which KPIs Will Help You
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Hi Experts,

there are two approached to pass sheet names vaue
1st approach:

JRXlsExporter exporter = new JRXlsExporter(); exporter.setParameter( JRXlsAbstractExporterParameter.SHEET_NAMES, new String[] {"first","second","third"} ); 

Open in new window


cant we pass this value as parameter in java?

this way(1st approach) i am unable to follow because i am sheduling report for a specificdate. and passing few parameter inputs as well for the same report.

sample:
Util.getParamString(stringBuilder, "GENERATEDON", Date);//similarly few more params i am passing

Open in new window


2nd approach:

iam setting in the report properties like below(2nd approach): Property Name = "net.sf.jasperreports.export.xls.sheet.names.all"

 Property Value = "first/second/third"

is there any chance to pass this property value as dynamic.?

I have tried like below as not works for me

<line> 
<reportElement x="0" y="-1" width="1" height="1"> 
<propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$F{course_name}]]></propertyExpression> 
</reportElement> 
</line>

Open in new window

1
Constructors are not inherited:
The sub class cannot inherit constructors from its super class. Consider the following example:
1
2
3
4
5
6
7
8
9
10
11
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 
public class Sub extends Super {
 
}
We can create a new instance of Super like this:
1
Super super = new Super(“Hello”);   //OK
But we cannot do the same for the Sub class:
1
Sub sub = new Sub(“Hello”); //Compile error, since constructor is not inherited
The solution is to write a constructor for the sub class and call the super’s constructor, for example:
1
2
3
4
5
6
public class Sub extends Super {
 
    public Sub(String text) {
        super(text);
    }
}

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i wrote as below

package SuperSub;
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 

Open in new window


package SuperSub;
public class Sub extends Super {
	//Super super = new Super(“Hello”);
}

Open in new window


i am getting error in line 2 of Sub class
Implicit super constructor Super() is undefined for default constructor. Must define an explicit constructor
package SuperSub;
public class Sub extends Super {

	public Sub(String text) {
		super(text);
		// TODO Auto-generated constructor stub
	}
	//Super super = new Super(“Hello”);
}

Open in new window

above is fine though not sure why i cannot just have Sub empty class?
Please advise
0
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        this.test();
}

Open in new window

why above code is not working
i see error as below at line 21,15
Syntax error, insert "}" to complete ClassBody

Please advise
0
The super keyword:
In Java, the superkeyword is used to access members of the super type from the sub type. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Super {
    protected void bar() {
        System.out.println("Super.bar()...");
    }
 
}
 
public class Sub extends Super {
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
        super.bar();
        this.bar();
    }
}
Here, we can see that both classes have a method called bar() (overriding). Therefore, if we want to invoke the super’s version of the bar() method, the super keyword is used.
 

Open in new window


super with this example not working for me
package SuperThis;
public class Sub extends Super {
	public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    //public void test() {
       // super.bar();
        //this.bar();
   // }
        
}

Open in new window


above code giving below error
Cannot use super in a static context
Cannot use this in a static context

how to fix this
package SuperThis;

public class Test {
public static void main(String[] args) {
	 Sub sub=new Sub();
	    sub.test();
}
}

Open in new window


Super.bar()...
Sub.bar()...


does it need separate class for this to test
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        test();
}

Open in new window

how to test in same Sub class

above gives error at line 20
Multiple markers at this line
      - This method requires a body instead of a
       semicolon
      - Return type for the method is missing
      - Duplicate method test() in type Sub

please advise
0
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i tried as below

package MultipleInheritance;
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class C extends A, B {
    public void methodC() {
        foo();
    }
}

Open in new window


on C class i get below error

Multiple markers at this line
      - Syntax error on token "extends", delete this token
      - Syntax error, insert "ClassBody" to complete
       ClassDeclaration
      - Syntax error, insert "}" to complete Block

can you please advise what above error means

it did not say "multiple inheritance of state not allowed"

Please advise
0
6. Multiple inheritance of state is not allowed:
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.
 
7. Multiple inheritance of type is allowed:
This means Java does allow multiple inheritance between interfaces. For example:
1
2
3
4
5
6
7
8
9
10
11
public interface X {
    public void methodX();
}
 
public interface Y {
    public void methodY();
}
 
public interface Z extends X, Y {
    public void methodZ();
}
This is allowed because interfaces do not have concrete methods, thus there is no ambiguity.
Likewise, we can have a class implements multiple interfaces:
1
2
3
4
5
6
7
public class Sub implements X, Y, Z {
    public void methodX() { }
 
    public void methodY() { }
 
    public void methodZ() { }
}

Open in new window


if both Interface X and Interface Y has same method called methodAB what happens?



Open in new window

0
Let’s look at the constructor of the Truckclass - it can access the protected field numberOfWheels and the default field name. However, it cannot access the private field age. We can write:
1
2
3
Truck truck = new Truck();
truck.start();
truck.move();
But the Java compiler will complain if we try to invoke the private method test():
1
truck.test();   // COMPILE ERROR, since private member is not inherited

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java


i supposed to put below code in which class Car or Truck or Moveable?


public class Truck extends Car {
    public Truck() {
        numberOfWheels = 8;
        name = "Truck";
        age=10;
    }
    
    Truck truck = new Truck();
    truck.start();
    truck.move();
    
}

Open in new window




or as below

public class Car extends Vehicle {
	String name;
	protected int age;
    //protected int age;
    protected int numberOfWheels = 4;
    
    public void move() {
        System.out.print("Moving by engine...");
    }

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}
	
	/*Truck truck = new Truck();
	truck.start();
	truck.move();*/
}

Open in new window


below i cannot put as it is interface

public interface Moveable {
    public void start();
 
    public void stop();
 
    public void move();
}

Open in new window


please advise
0
Don’t use a for loop with an index (or counter) variable if you can replace it with the enhanced for loop (since Java 5) or forEach (since Java 8). It’s because the index variable is error-prone, as we may alter it incidentally in the loop’s body, or we may starts the index from 1 instead of 0.
Consider the following example that iterates over an array of Strings:
1
2
3
4
5
String[] names = {"Alice", "Bob", "Carol", "David", "Eric", "Frank"};
 
for (int i = 0; i < names.length; i++) {
    doSomething(names[i]);
}
As you can see, the index variable i in this for loop can be altered incidentally which may cause unexpected result. We can avoid potential problems by using an enhanced for loop like this:
1
2
3
for (String aName : names) {
    doSomething(aName);
}
This does not only remove potential issues but also make the code cleaner and more succinct. 

Open in new window


how is it possible to do for loop index modifycation?

how enhanced for loop is diferent from for each loop?

is there any case where we still has to use traditional for loop with index
please advise
0
public class CollectionsRef {
 
    private HashSet<Integer> numbers;
 
    public ArrayList<String> getList() {
 
        return new ArrayList<String>();
    }
 
    public void setNumbers(HashSet<Integer> numbers) {
        this.numbers = numbers;
    }
}
Look at the reference types which are collection implementation classes - this locks the code to work with only these classes HashSet and ArrayList. What if we want the method getList() can return a LinkedList and the method setNumbers() can accept a TreeSet?
The above class can be improved by replace the class references to interface references like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class CollectionsRef {
 
    private Set<Integer> numbers;
 
    public List<String> getList() {
        // can return any kind of List
     [b]   return new ArrayList<String>();[/b]
    }
 
    public void setNumbers(Set<Integer> numbers) {
        // can accept any kind of Set
        this.numbers = numbers;
    }
}

Open in new window


can we have generic List as return type to provide more flexibility to future changes to collection implementation?
https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0
Microsoft Azure 2017
LVL 12
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Avoid Redundant Initialization (0-false-null)
It’s very unnecessary to initialize member variables to the following values: 0, false and null. Because these values are the default initialization values of member variables in Java. For example, the following initialization in declaration is unnecessary:
1
2
3
4
5
public class Person {
    private String name = null;
    private int age = 0;
    private boolean isGenius = false;
}
This is also redundant:
1
2
3
4
5
6
7
8
9
10
11
public class Person {
    private String name;
    private int age;
    private boolean;
 
    public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}
Therefore, if you know the default initialization values of member variables, you will avoid unnecessary explicit initialization. See more here:

Open in new window


i am not clear on below

This is also redundant:


does it mean initialization in the constructor as well apart from at class level

public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}

https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0
It’s a very bad idea to create an interface which is solely for declaring some constants without any methods. Here’s such an interface:
1
2
3
4
5
public interface Color {
    public static final int RED = 0xff0000;
    public static final int BLACK = 0x000000;
    public static final int WHITE = 0xffffff;
}
It’s because the purpose of interfaces is for inheritance and polymorphism, not for static stuffs like that. So the best practice recommends us to use an enum instead. For example:
1
2
3
public enum Color {
    BLACK, WHITE, RED
}
In case the color code does matter, we can update the enum like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public enum Color {
 
    BLACK(0x000000),
    WHITE(0xffffff),
    RED(0xff0000);
 
    private int code;
 
    Color(int code) {
        this.code = code;
    }
 
    public int getCode() {
        return this.code;
    }
}

Open in new window


what is the meaning of color code does not matter and updating like below?

In case the color code does matter, we can update the enum like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public enum Color {
 
    BLACK(0x000000),
    WHITE(0xffffff),
    RED(0xff0000);
 
    private int code;
 
    Color(int code) {
        this.code = code;
    }
 
    public int getCode() {
        return this.code;
    }
}

Open in new window

https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know

when we create special AppConstants class?
can there be interface just for constants?
please advise
0
String sql = "Insert Into Users (name, email, pass, address)";
sql += " values ('" + user.getName();
sql += "', '" + user.getEmail();
sql += "', '" + user.getPass();
sql += "', '" + user.getAddress();
sql += "')"[b][u];[/u][/b]

Open in new window

in above StringBuilder example why ; is not in double quotes?
https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
https://www.w3schools.com/sql/sql_insert.asp

same question i have with StringBuilder as well
StringBuilder sbSql
    = new StringBuilder("Insert Into Users (name, email, pass, address)");
 
sbSql.append(" values ('").append(user.getName());
sbSql.append("', '").append(user.getEmail());
sbSql.append("', '").append(user.getPass());
sbSql.append("', '").append(user.getAddress());
sbSql.append("')");
 
String sql = sbSql.toString();


why we need to do toString only in case of StringBuilder

also what it mean by String builder not thread safe and string buffere thread safe

any example or link to prove this theory into practical?
Please advise
0
class Parent {
	//Parent(){}
	Parent(){}
    Parent(int number) {
    }
}
 
class Child extends Parent {
    Child(int a, int b) {
    }
}

Open in new window


for above code do not i need to give  constructor as below with two arguments?


      Parent(int a, int b){}
//if i give constructor like above does it still called default constructor?

what is the meaning of below sentence?
4. The default constructor is only generated by the compiler:
If we explicitly write a constructor that looks exactly the same as the default constructor, it is NOT called the default constructor.
https://www.codejava.net/java-core/the-java-language/9-rules-about-constructors-in-java
Please advise
0
Hi,

I went through https://www.callicoder.com/reactive-rest-apis-spring-webflux-reactive-mongo/ and need clarifications on the below

In previous version we have to specify as below to return the output as Json

@RequestMapping(value = "/getString", method = RequestMethod.GET, produces = "application/json")

How to return the response as Json in new Spring 5 ?

In earlier version we can return a stream directly to the browser to process to the front end. either stream or base64 url. How to return a stream in the current spring 5 version

Where i can find out the syntax differences between spring earlier and spring 5 version

Thanks.
0
I have a form with a Datagridview on it and I need to filter it on a field called BulkSaleNumber. I need help with the statement to filter the Datagridview for all records where the BulkSaleNumber =0. How do I filter the Datagridview so that it will list only those rows where the BulkSaleNumber =0?. Please see my code below.


    
        Private Sub frmBulkSale_Load(sender As Object, e As EventArgs) Handles MyBase.Load
             'TODO: This line of code loads data into the 'AssetDatabaseDataSet.tblAssetData' table. You can move, or remove it, as needed.
              Me.TblAssetDataTableAdapter.Fill(Me.AssetDatabaseDataSet.tblAssetData)
        End Sub

Open in new window

0
Hi Experts,

I need your help as I'm new to programming.  Could you please help me out with a solution for the below program?

The program simulates different errors that the protocol checks for.

           Modify the program so that it implements "time out".

          Theory:

          Sender: sends a frame and calls a SIGALRM function and sets the timer

           for say 2 seconds. If the sender gets a response within two seconds

           from the receiver (either "ACK" or "NAK"), turn off the alarm and

           transmit the next frame. If no response is received, time out function

           kicks in and retransmits the frame.

           Receiver: When it sees an error in transmission, do not send back

           anything to the sender and this causes the time out and retransmit.


sender_c.txtreceiver_c.txt
0
Hi,
I'm using power builder 12.5 version  and I want to disable the double click event for  a particular column in data window control.
double click event script contains nothing.
Could you please let me know how can I disable the double click for a single column?
0
I have a cordova app and would like to make some changes to the build.gradle file. Basically, I would like to remove some lines (with **) and add some new statements (*)

I have added the lines but when I build my code with  cordova  the gradle file gets regenerated and my changes are lost.

I know that I can use the android studio but I am automating my process and would do it with my current automation script

Can you please let me know how to make this change with maybe gradle.extra file

I am using Cordova 6.5.0

Thanks for the help

here is the snippet from the build.gradle file

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    **//compile "com.google.android.gms:play-services-gcm:11.+"**
    compile "com.android.support:support-v4:24.1.1+"
    compile "com.squareup.okhttp:okhttp-urlconnection:2+"
    **//compile "com.google.android.gms:play-services-gcm:+"**
    *compile 'com.google.firebase:firebase-messaging:10.2.6'
    // SUB-PROJECT DEPENDENCIES END
}
*apply plugin: 'com.google.gms.google-services'

Open in new window

0
Determine the Perfect Price for Your IT Services
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Hi,

Is there a way to calculate percentile rank using a conditional statement. For example, PERCENTRANK.EXC of column Ratio if Rating value is AAA. Example is attached.

Thanks
EE-example.xlsx
0
Hi,

I am unable to understand how we can derive: (S,K and cap are positive integers)

3*( max(S-K,0) – max(S – (K+Cap/3),0))

from

3* min(max((S – K,0), Cap/3)

From plugging values in 3* min(max((S – K,0), Cap/3) , I can see that it is equivalent. But how do i think about this?

Thanks
1
Search Values in Excel worksheet

I have 2 Excel worksheets, they are the same. I mean same column names

on Worksheet 2 I would like to compare each row based on Column A with all rows of worksheet 1 and see if it exists

exmaple:
worksheet1 has a column A

Column A

awcds
mkhgc
fgtyol
etc..


on Worksheet column A
hgbnht
pppp
ggtg
mkhgc
jhtyu

I want the code to grab the first data of column A in worksheet 2 and look it up on Worksheet 1 Column A if it finds it it will write for instance on column P of worksheet 2 how many times it found that Data in Column A Worksheet 1

Thank you
0
HI,
The problem is to design a solution for finding the number of users who are watching a particular video eg. on youtube etc.
Here is what i thought about solving it.
If the video is playing than every 5th minute from GMT it will send a play event
I will maintain a table containing  (userId, movieId, timeStamp)
So to count how many viewers playing a video i will simply have to count the number of entries in the table with the movieID and timeStamp not later than 5 minutes. Because if a play event is not recieved for 6 minutes than the video must not be playing...
And each time a play event is received the timeStamp will be updated to the current time.

Also i will run a cronJob that will be clearing entries that are not getting updated.
Will maintain a cache containing the count for each movie and will update it at a regular interval from the table.

Each video that is being played will send a https request for the number of current viewers every 6th minute and the number of viewers will be updated.
Please suggest if there is any flaw in this approach. or any better approach ?
Any pros and cons ?
Thanks
0
Type-ahead search like google

Does any open source software has this feature to index huge document and search as type-ahead like google for a text?
0
Looking for a GUI Github software that will download all repositories from a user, without having to do each repository separately.

I have done some searching and couldn't find this in any GUI software, only with CLI.

Thanks in advance for your help,
Future Developer
0

Programming

52K

Solutions

40K

Contributors

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.