2 Replies - 1203 Views - Last Post: 10 May 2008 - 10:15 AM Rate Topic: -----

#1 emily327  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 09-May 08

the method openFName() from the type WordPadOpen is not static

Posted 09 May 2008 - 07:42 AM

The WordPadOpen class creates a file name based on the calling script, then opens a WordPad document under that name. The callWordPadOpen class is a test of how the first would be instantiated in a number of other scripts (all separate files). I keep getting an error on the line "String opened = WordPadOpen.openFName();" (in the callWordPad class) that says "method openFName() from the type WordPadOpen is not static." But I can't see any reason why it would need to be, and if I make it, then all the calls inside it to things like "documentWordPadwindow" and "comboBox" complain that they need to be static, but they are from a recorded script that is not supposed to be changed. How do I fix it?

package Components;

import resources.Components.WordPadOpenHelper;
import java.util.*;//for GregorianCalendar
import java.text.*;//for GregorianCalendar
// @author Steve

public class WordPadOpen extends WordPadOpenHelper
{
	Date today;
	String result;
	SimpleDateFormat formatter;

	public void testMain(Object[] args)
	{
		try
		{
			openFName();
		}// end try
		catch (Exception e)
		{
			logError("Exception thrown from WordPadOpen.class");
		}// end catch
	}// end testMain
	
	public String openFName() 
	{
		
			Locale oToday = null;
			boolean bExist = true;
			boolean bWPExists = true;
			Date today;
			String result;
			SimpleDateFormat formatter;
			
 /* Blocked out by Emily 5/8/08 - next block of code performs similarly			
			for (int i = 0; i < args.length; ++i)
			{
				System.out.println( " arg["+i+"] = "+args[i]);
			}
			System.out.println(args[0]);
			System.out.println("Passed data array is "+args[0]);		
 */	
			
			String[] fName = new String[2];
	 		fName[0] = getTopScriptName();
	 		fName[1] = Integer.toString(getTopScriptLineNumber());
	 		for (int i = 0; i < fName.length; i++)  {
	 			System.out.println(fName[i]);
	 		}
	 		logInfo(fName[0]);
	 		
			do
			{	
				bWPExists = documentWordPadwindow().exists();
				if (bWPExists == true)
				{
					logInfo("Closed open WordPads");
					callScript("WordPadClose");
				}// end if
				else
				{
					bWPExists = false;
					//logInfo("Did not detect macro pop-up");	
				}// end else
			}// end do
			while(bWPExists == true);// end do while	
			
		   	shellExecute("wordpad.exe"); 
			sleep(1);
			//tFrame().inputKeys("%{PRTSC}");
			//documentWordPadwindow(ANY,MAY_EXIT).inputKeys("^v");
			documentWordPadwindow(ANY,MAY_EXIT).inputKeys("^s");
		
			oToday = new Locale("en", "US");
			formatter = new SimpleDateFormat("yyyy.MMM.dd.kk.mm", oToday);//, currentLocale // EEE d MMM yy
			today = new Date();
			result = formatter.format(today);
		
			//System.out.println("Locale: " + oToday.toString());
			//System.out.println("Result: " + result);
			//logInfo("Locale: " + oToday.toString());
			logInfo("Result: " + result);		 //}
			
			//		logInfo("Script name is " + sTSN +" from line number " + iSLN);
			//		saveAswindow().inputChars(iSLN + sTSN +" "+ result +".rtf");
			logInfo("Script name is "+fName[0]+" from line number "+fName[1]);
			//saveAswindow().inputChars(fName[0]+" "+" "+result+".rtf");
			saveAswindow().inputChars(fName[0]+" "+" "+result+".doc");
	
			desktopbutton().click(atPoint(32,56));
			
		
		// Window: wordpad.exe: Save As
		comboBoxcomboBox2().click(ARROW);
		comboBoxcomboBox2().click(atPoint(185,7));
		saveAswindow().inputChars(".");
		savebutton().click(atPoint(39,16));	
		return fName[0];
		
		
	}// end openFName
}// end class WordPadOpen



package Components;

import resources.Components.callWordPadOpenHelper;
import Components.WordPadOpen;

public class callWordPadOpen extends callWordPadOpenHelper
{
	public void testMain(Object[] args)
	{
		String opened = WordPadOpen.openFName();
		System.out.println("Opened the file " + opened);
		logInfo("Opened file " + opened);
	}
}// end class callWordPadOpen



Is This A Good Question/Topic? 0
  • +

Replies To: the method openFName() from the type WordPadOpen is not static

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: the method openFName() from the type WordPadOpen is not static

Posted 09 May 2008 - 08:50 AM

public class callWordPadOpenHelper
{
	public void testMain(Object[] args)
	{
		String opened = WordPadOpen.openFName();
		System.out.println("Opened the file " + opened);
		logInfo("Opened file " + opened);
	}
}// end



The method openFName() is not static. It has to be static if you want to call that way

		String opened = WordPadOpen.openFName();



But this probably not what you want to do.
You have to create first an Object of type WordPadOpen and then you can call the instance of openFName() of that object

   WordPabOpen wpo = new WordPadOpen();
   String opened = wpo.openFName();


Was This Post Helpful? 0
  • +
  • -

#3 emily327  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 09-May 08

Re: the method openFName() from the type WordPadOpen is not static

Posted 10 May 2008 - 10:15 AM

I tried something very similar to that, and it was still throwing the error, but perhaps I made a mistake. I will try that when I get back to work on Monday. Thanks!

This post has been edited by emily327: 10 May 2008 - 10:19 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1