How to use PrivateProfileString()

I am attempting to follow the example at:


to store user settings between sketch invocations. I am using the Eclipse IDE to develop it.

In this code snippet:

        /** default starting directory where browsing for an output file to write to will start */
	public File fStartingDataFilePath = new File( "C:\\Hotfix\\*.csv" );

	/** ini file section for files */
	public String sIniSectFile = "Files";
	
	/** ini file key for default ouput data file path */
	public String iIniKeyDataFilePath = "DataFilePath";

...

        System.PrivateProfileString( sIniFile, sIniSectFile,  iIniKeyDataFilePath) = fStartingDataFilePath.getAbsolutePath();

I get two errors on the last line above:

Multiple markers at this line
	- The method PrivateProfileString(String, String, String) is undefined for the type 
	 System
	- The left-hand side of an assignment must be a variable

The second error is easy for me to understand because I have never before seen a function, or method, call set equal to something. Yet that is what that example does.

The first error means my version of the System class does not have the PrivateProfileString method. What do I need to import to have this?

What is the right way to do this?

Hello spflanze
Could you show us the code in the example that you used?

Otherwise you could try it with a java library for editing .ini files. One such library would be:
http://ini4j.sourceforge.net/

1 Like

Thanks for this ini4j. I have decided to use it. The download gave me two libraries:

ini4j-0.5.4.jar
ini4j-0.5.4-jdk14.jar

I do not know which to use. Under what circumstance is each one to be used?

@Chrisir is the one who posted that code snippet you linked from 2014 – but I believe that is VBA (Visual Basic for Applications) code, not Processing!