How Can I Save and Change a String

Discuss issues and ideas you have to configuring displays with PowerVision
ergun
Posts: 2
Joined: Tue May 03, 2011 7:43 am

How Can I Save and Change a String

Post by ergun » Sun Aug 24, 2014 5:36 am

I want to save and change a string. I will entry a string from keyboard and i want to save that string to eeprom. Also i want to change last saved string how can i do this could me help please .
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: How Can I Save and Change a String

Post by stalley » Tue Aug 26, 2014 5:33 pm

Hi Ergun,

Thank you for your question! The answer requires some scripting to accomplish what you want to do. This is a very simple example, I'm sure you will have something with more logic, but hopefully this will give you an idea of what you will need to do.

First I created a String Variable, NameString.

On start up, I have the following code executing:

Code: Select all

void $InitializeString$ ()
{

	file f;
	string str = "";
	int fStatus;
	int fSize = 0;
	if (f.open( "stringToSave.txt", "r" ) >= 0 )
 	{
		fSize = f.getSize();
		if (fSize > 0)
		fStatus = f.readString(fSize, str);
	}
	f.close();
	smWrite(VariableIDs.fileStatus, fStatus);
	
	if (str != "")
	{	
		cultureSetString(StringIDs.NameString, str, true);
	}

}
When I want to save the NameString variable:

Code: Select all

{
	file f;
	string str;
	if (f.open( "stringToSave.txt", "w" ) >= 0 )
 	{
		cultureGetString(StringIDs.NameString, str, 0);
		f.writeString(str);
	}
	f.close();
}
When you edit a script, there are tabs for Function Reference and Scripting Syntax Reference. These are helpful and provide more information about the valid parameters to the functions and what functions are available!
Sara Talley
Software Engineer
Enovation Controls
bburgess
Posts: 2
Joined: Thu Oct 06, 2011 3:06 pm

Re: How Can I Save and Change a String

Post by bburgess » Thu Dec 25, 2014 6:03 am

Saving keybord generated STRING: Do you have a simplified means to save to PV450' 780 NV memory?
:shock:
jpratt
Enovation Controls Development
Enovation Controls Development
Posts: 222
Joined: Mon Jun 21, 2010 11:18 am

Re: How Can I Save and Change a String

Post by jpratt » Thu Dec 25, 2014 11:36 am

The example above shows the current easiest way to save and restore a string from the flash (NV). We will add support for using actions to save strings in a future versions.
Jake Pratt
Software Development Manager