Wednesday, April 16, 2008
DOS Command To Delete Those Files Having Attribute Other than A
If you want to delete the files that have their Attribute value equal to "-A"(Other than A), Use the following Command:
DEL /Q /A:-A *.*
Where:
/A is a switch that selects files to delete based on attributes
-A means that only those files that have attribute value other than A
/Q is a switch for Quiet mode, do not ask if ok to delete on global wildcard
and
*.* means all files.
For further details you can visit the following reference page.
http://www.computerhope.com/delhlp.htm
DEL /Q /A:-A *.*
Where:
/A is a switch that selects files to delete based on attributes
-A means that only those files that have attribute value other than A
/Q is a switch for Quiet mode, do not ask if ok to delete on global wildcard
and
*.* means all files.
For further details you can visit the following reference page.
http://www.computerhope.com/delhlp.htm
Tuesday, April 8, 2008
JAvaScript function to Count no Of Specific Fields( Like TextBoxes)
Sometimes, you create textboxes or othe form fields dynamically using some server side scripting language. Then you may need to count the number of fields using some JAvaScript. The following javascript function will return the no of specific fields of a form passed in parameters:
It has two parameters:
1- formName:- It is the attribute name of the form
2- inputtype:- Type of Field as a String argument.
For Example if you would like to count the number of textBoxes in the HTML form, the following call will work.
var noOfTextBoxes = countElement(formName,"text");
Similarly, to count no of buttons in HTML form, call the function like:
var noOfTextBoxes = countElement(formName,"button");
Here is the implementation of JavaScript function:
function countElement(formName,inputtype)
{
var count =0;
for(i=0; i < formName.elements.length ; i++ )
{
if(formName.elements[i].type==inputtype)
{
//
alert(formName.elements[i].value);
count=count+1;
}
}
return count;
}
It has two parameters:
1- formName:- It is the attribute name of the form
2- inputtype:- Type of Field as a String argument.
For Example if you would like to count the number of textBoxes in the HTML form, the following call will work.
var noOfTextBoxes = countElement(formName,"text");
Similarly, to count no of buttons in HTML form, call the function like:
var noOfTextBoxes = countElement(formName,"button");
Here is the implementation of JavaScript function:
function countElement(formName,inputtype)
{
var count =0;
for(i=0; i < formName.elements.length ; i++ )
{
if(formName.elements[i].type==inputtype)
{
//
alert(formName.elements[i].value);
count=count+1;
}
}
return count;
}
Monday, April 7, 2008
JAVA@ Removing Duplicate Records from ArrayList
The following code removes the duplicate records from the ArrayList of Java.
//////////////////////////////////////
import java.util.ArrayList;
public class RemoveDuplicateArrayElement {
public static void main(String [] as)
{
// String [] temp={"sqqa","as","sa","sd","sa","fd","sa","sa","sa"};
ArrayList aryDuplicate=new ArrayList();
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("irfan"));
aryDuplicate.add(new String("waqas"));
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("Ahmad"));
// for(int i=0;i
// {
// if(listContains(aryL,temp[i]))
// {
// // This is already in the List, Don't push it.
// //System.out.println("List already contains"+temp[i]);
// }
// else
// {
// aryL.add(new String(temp[i]));
// }
// }
// aryDuplicate1=aryDuplicate;//
//
// for(int j=0;j
// {
// //System.out.println(j+":"+(String)aryDuplicate1.get(j));
// }
aryDuplicate=RemoveDuplicates(aryDuplicate);
System.out.println(aryDuplicate.size());
for(int j=0;j
{
System.out.println(j+":"+(String)aryDuplicate.get(j));
}
//System.out.println("List contains = "+listContains(aryL,"sfa") );
}
/////////////////////////////////////
public static ArrayList RemoveDuplicates(ArrayList aryLst)
{
ArrayList noDuplicate=new ArrayList();
for(int i=0;i
{
if(listContains(noDuplicate,(String)aryLst.get(i)))
{
//This is already in the List, Don't push it.
// System.out.println((String)aryLst.get(i));
}
else
{
noDuplicate.add(new String((String)aryLst.get(i)));
}
}
return noDuplicate;
}
/////////////////////////
public static boolean listContains(ArrayList aryList, String str)
{
boolean result=false;
for(int i=0;i
{
// System.out.println((String)aryList.get(i));
if(str.equalsIgnoreCase((String)aryList.get(i)))
{
result= true;
break;
}
else
{
result= false;
}
}
return result;
}
///////////////////////////////////
public static boolean listContains(String[] aryList, String str)
{
boolean result=false;
for(int i=0;i
{
// System.out.println((String)aryList.get(i));
if(str.equalsIgnoreCase((String)aryList[i]))
{
result= true;
break;
}
else
{
result= false;
}
}
return result;
}
} // end class
//////////////////////////////////////
import java.util.ArrayList;
public class RemoveDuplicateArrayElement {
public static void main(String [] as)
{
// String [] temp={"sqqa","as","sa","sd","sa","fd","sa","sa","sa"};
ArrayList aryDuplicate=new ArrayList();
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("irfan"));
aryDuplicate.add(new String("waqas"));
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("sabah"));
aryDuplicate.add(new String("Ahmad"));
// for(int i=0;i
// {
// if(listContains(aryL,temp[i]))
// {
// // This is already in the List, Don't push it.
// //System.out.println("List already contains"+temp[i]);
// }
// else
// {
// aryL.add(new String(temp[i]));
// }
// }
// aryDuplicate1=aryDuplicate;//
//
// for(int j=0;j
// {
// //System.out.println(j+":"+(String)aryDuplicate1.get(j));
// }
aryDuplicate=RemoveDuplicates(aryDuplicate);
System.out.println(aryDuplicate.size());
for(int j=0;j
{
System.out.println(j+":"+(String)aryDuplicate.get(j));
}
//System.out.println("List contains = "+listContains(aryL,"sfa") );
}
/////////////////////////////////////
public static ArrayList RemoveDuplicates(ArrayList aryLst)
{
ArrayList noDuplicate=new ArrayList();
for(int i=0;i
{
if(listContains(noDuplicate,(String)aryLst.get(i)))
{
//This is already in the List, Don't push it.
// System.out.println((String)aryLst.get(i));
}
else
{
noDuplicate.add(new String((String)aryLst.get(i)));
}
}
return noDuplicate;
}
/////////////////////////
public static boolean listContains(ArrayList aryList, String str)
{
boolean result=false;
for(int i=0;i
{
// System.out.println((String)aryList.get(i));
if(str.equalsIgnoreCase((String)aryList.get(i)))
{
result= true;
break;
}
else
{
result= false;
}
}
return result;
}
///////////////////////////////////
public static boolean listContains(String[] aryList, String str)
{
boolean result=false;
for(int i=0;i
{
// System.out.println((String)aryList.get(i));
if(str.equalsIgnoreCase((String)aryList[i]))
{
result= true;
break;
}
else
{
result= false;
}
}
return result;
}
} // end class
Subscribe to:
Posts (Atom)