Improvement requests :  K-Meleon Web Browser Forum
Use this forum to talk about a feature you're missing. 
macro command: writefile()
Posted by: disrupted
Date: June 18, 2009 06:34PM

enables writing to text based files

e.g
writefile([path],[string],[line #])

if line no. is 0 or omitted= append string to last line

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JujuLand
Date: June 18, 2009 08:18PM

I think you want it to manage you list for the string chooser.

A way is perhaps to use an inifile instead of simple text file, and you will then be able to update strings in it.

For this just use utils kplugins of mark307.

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: macro command: writefile()
Posted by: desga2
Date: June 18, 2009 08:58PM

You can add it to prefs.

Take a look to this extension, it's similar to how work Flashblock extension whitelist, but you are meking a blacklist. smiling smiley

Almost I think that Dorian implemented a new macro functions in 1.5.3 to read and write ini files. You can look it in macro sources:
At the end of file you can show a list of all macro functions;
 1444 	MACROSFUNC_ADD(iniread);
 1445 	MACROSFUNC_ADD(iniwrite);

In code are defined like:
 1376 	Value iniread(FunctionData* data)
 1377 	{
 1378 		checkArgs(__FUNCTION__, data, 4);
 1379 		std::string buffer;
 1380 		::GetPrivateProfileStringUTF8(data->getstr(1), data->getstr(2), data->getstr(3), buffer, data->getstr(4));
 1381 		return buffer;
 1382 	}
 1383 
 1384 	Value iniwrite(FunctionData* data)
 1385 	{
 1386 		checkArgs(__FUNCTION__, data, 4);
 1387 		return ::WritePrivateProfileStringUTF8(data->getstr(1), data->getstr(2), data->getstr(3), data->getstr(4));
 1388 	}

But is dificult know how work it (parameters needed and optional) without documentation about. I only know that both use 4 parameters string type.

This could be:
$VAR = iniread ("file_path", "Group", "Item", "Default value if not exist?");
iniwrite ("file_path", "Group", "Item", "Value");

But I'm not sure about order in parameters.
Also is possible that functions aren't fully implemented yet (functions incomplete or not work fine yet).

K-Meleon in Spanish



Edited 1 time(s). Last edit at 06/18/2009 08:59PM by desga2.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: disrupted
Date: June 18, 2009 09:10PM

parfait! exactly what i wanted.. i used mark's utils.. much easier..if string(host) already exists.. no big deal it will still function properly. don't want to make it too complicated also don't want to be responsible for user's amnesia tongue sticking out smiley

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 24, 2009 06:34PM

I am doing some testing on the new macro statements, iniwrite and iniread. I have some things working and will include a demo macro for that. There is a question about the action of a null value. The information on WritePrivateProfileString from http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx would lead me to expect that if the value for a key is null then the key would be removed. I am using value = "" to write a null. Am I incorrect in using "" to indicate a null value? I am getting the value changed to "" but the key remains.

The menu for this demo appears under the Help menu.

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ini_Demo.kmm
# ---------- Valid for KM 1.5.3 ---------------
#
# Dependencies        : main.kmm
# Resources           : ini_Demo.ini
# Preferences         : -
# Version             : 0.2  6/24/09  JamesD 
# --------------------------------------------------------------------------------

_ini_Demo_RunCode{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_ini_Demo_Value = "Common" ;
alert($_ini_Demo_Path, "Proposed file name", INFO);
alert($_ini_Demo_Section, "Proposed section name", INFO);
alert($_ini_Demo_Item, "Proposed item name", INFO);
alert($_ini_Demo_Value, "Proposed item value", INFO);
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO); 
}

_ini_Demo_RunCode2{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_Value = iniread($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert($_Value, "item value", INFO); 
}

_ini_Demo_RunCode3{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_ini_Demo_Value = "" ;
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
}


_ini_Demo_BuildMenu{
	# add another option to Help menu
$_ini_Demo_Popm = "ini Demo Testing" ;
setmenu("KMDocs",popup,$_ini_Demo_Popm,3);
setmenu($_ini_Demo_Popm,"macro","Writing","_ini_Demo_RunCode");
setmenu($_ini_Demo_Popm,"macro","Reading","_ini_Demo_RunCode2");
setmenu($_ini_Demo_Popm,"macro","Delete item","_ini_Demo_RunCode3");
}

_ini_Demo_GetPath{
## assumes that "ini_Demo.kmm" is in UserMacroFolder
$_ini_Demo_Path=getfolder(UserMacroFolder)."\\ini_Demo.ini";
}

# - - - - - - - - - - - - - - -
$OnStartup=$OnStartup."_ini_Demo_GetPath;";
$OnInit=$OnInit."_ini_Demo_BuildMenu;";
$macroModules=$macroModules."ini_Demo;";



Options: ReplyQuote
Re: macro command: writefile()
Posted by: desga2
Date: June 24, 2009 07:41PM

Great work JamesD! smiling smiley
A good idea search the C++ functions in msdn Library, I didn't think in it.
Don't worry for Null values, If a key don't have value (is = "") when you use iniread function this must return a null value.

But, are you tried as null value; "NULL" or 0?
Also you can try with "\n" or "\t" as null characters.

(I think some languajes use -0 or +0 for NULL value)

K-Meleon in Spanish



Edited 2 time(s). Last edit at 06/24/2009 07:45PM by desga2.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 24, 2009 11:48PM

@ desga2

I have tried everything I can think of for a null value. I have even tried leaving out the variable name and just having the commas for placeholders but nothing seems to work. I don't know if this is a bug or the work in incomplete. I want to start work on updating Macrolibary2, but I don't want to put incomplete data or incorrect data there.

I am including my most up-to-date test files. Some things work just fine.
Write ini file           - works
Read ini file            - works
Overwrite ini info       - works
Delete item from file    - not as expected
Delete section from file - not as expected
Delete the ini file      - works ( using JScript )

ini_Demo.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ini_Demo.kmm
# ---------- Valid for KM 1.5.3 ---------------
#
# Dependencies        : main.kmm
# Resources           : ini_Demo.ini, ini_Demo.js
# Preferences         : -
# Version             : 0.5  6/25/09  JamesD 
# --------------------------------------------------------------------------------

_ini_Demo_RunCode{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_ini_Demo_Value = "Common" ;
alert($_ini_Demo_Path, "Proposed file name", INFO);
alert(" section name  ".$_ini_Demo_Section."\n item name      ".$_ini_Demo_Item."\n item value      ".$_ini_Demo_Value, "Proposed field values", INFO); 
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO); 
}

_ini_Demo_RunCode2{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_Value = iniread($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert($_Value, "item value", INFO);
$_Value==""?0:alert(readfile($_ini_Demo_Path), "The file as written", INFO);  
}

_ini_Demo_RunCode3{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_ini_Demo_Value =  ;
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
$_ini_Dtext1 = "As you can see, this does not delete \n" ;
$_ini_Dtext2 = "the line as expected.  The value for the \n " ;
$_ini_Dtext3 = "item Orange has been set equal to blank." ; 
alert($_ini_Dtext1.$_ini_Dtext2.$_ini_Dtext3, "Delete item", INFO);
}

_ini_Demo_RunCode4{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item =  ;
$_ini_Demo_Value =  ;
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
$_ini_Dtext1 = "As you can see, this does not delete \n" ;
$_ini_Dtext2 = "the section as expected.  The value for the \n " ;
$_ini_Dtext3 = "item Orange is unchanged, and a blank \n" ;
$_ini_Dtext4 = "equal blank line has been created. " ;
alert($_ini_Dtext1.$_ini_Dtext2.$_ini_Dtext3.$_ini_Dtext4, "Delete item", INFO);
}

_ini_Demo_RunCode5{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Item = "Orange" ;
$_ini_Demo_Value = "Unique" ;
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);

}

_ini_Demo_RunCode6{
exec("wscript.exe \"".$_ini_Demo_JSpath."\" \"".$_ini_Demo_Path."\"");
}

_ini_Demo_BuildMenu{
	# add another option to Help menu
$_ini_Demo_Popm = "ini Demo Testing" ;
setmenu("KMDocs",popup,$_ini_Demo_Popm,3);
setmenu($_ini_Demo_Popm,"macro","Writing","_ini_Demo_RunCode");
setmenu($_ini_Demo_Popm,"macro","Reading","_ini_Demo_RunCode2");
setmenu($_ini_Demo_Popm,"macro","Delete item","_ini_Demo_RunCode3");
setmenu($_ini_Demo_Popm,"macro","Delete section","_ini_Demo_RunCode4");
setmenu($_ini_Demo_Popm,"macro","Overwrite item","_ini_Demo_RunCode5");
setmenu($_ini_Demo_Popm,"macro","Delete ini file","_ini_Demo_RunCode6");
}

_ini_Demo_GetPath{
## assumes that "ini_Demo.kmm" and "ini_Demo.js" are in UserMacroFolder
$_ini_Demo_Path=getfolder(UserMacroFolder)."\\ini_Demo.ini";
$_ini_Demo_JSpath =getfolder(UserMacroFolder)."\\ini_Demo.js";
}

# - - - - - - - - - - - - - - -
$OnStartup=$OnStartup."_ini_Demo_GetPath;";
$OnInit=$OnInit."_ini_Demo_BuildMenu;";
$macroModules=$macroModules."ini_Demo;";

ini_Demo.js


/* ini_Demo.js by JamesD, version  0.1   2009-06-25

   This script is a helper application for the K-Meleon Macro Module ini_Demo.kmm that
   enables you to delete an ini file.
   
   Windows Script Host 2.0 (or better) required!
   
   WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is
   available at http://msdn.microsoft.com/scripting/
*/
var Current_iniFile_Path  = WScript.Arguments(0);
var obj = new ActiveXObject("Scripting.FileSystemObject");
if ( obj.fileExists(Current_iniFile_Path))
	{obj.DeleteFile ( Current_iniFile_Path );
	}



Edited 1 time(s). Last edit at 06/24/2009 11:50PM by JamesD.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JujuLand
Date: June 25, 2009 07:43AM

Hum, I don't think it's a good idea to use a wsh script. Instead of it, you can use the exec command:

exec("cmd /c del ".$inifile);

Windows scripts are shit, and don't work under Linux...

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc





Edited 1 time(s). Last edit at 06/25/2009 07:44AM by JujuLand.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 25, 2009 12:01PM

Quote
JujuLand
Hum, I don't think it's a good idea to use a wsh script. Instead of it, you can use the exec command:

exec("cmd /c del ".$inifile);

I have used the exec cmd statement, but it has not worked for me. Have I done the statement wrong?

_ini_Demo_RunCode6{
#exec("wscript.exe \"".$_ini_Demo_JSpath."\" \"".$_ini_Demo_Path."\"");
exec("cmd /c del ".$_ini_Demo_Path); 
}

You are right that this will be the better solution if I can get it working.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JujuLand
Date: June 25, 2009 01:09PM

Hum, I forget to precise that this doesn't work for w9x, where the command must be:

exec("command /c del ".$_ini_Demo_Path);

You must, before sending this command test the OS, for example by testing some env variable or the presence of a file (cmd.exe or command.com). File testing or env reading must be present in mark307 utils kplugin.

Try also to indicate the complete cmd or command path, or perhaps just the extension

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc





Edited 2 time(s). Last edit at 06/25/2009 01:17PM by JujuLand.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: desga2
Date: June 25, 2009 02:56PM

@ JamesD:
Are you tried with this?

iniwrite($_ini_Demo_Section, $_ini_Demo_Item, , $_ini_Demo_Path);

K-Meleon in Spanish

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 25, 2009 07:39PM

@ Jujuland

I tried 'exec("cmd.exe");' and I had the Cmd window stay open with info like this"
Microsoft Windows XP ver 5.1.2600
copyright line

C:\Program Files\k-meleon>

This means that my 'cmd.exe' file is present and working, right?

@ Desga2

I tried omitting the field(s) where I wanted a null. I saw no change to the ini file. I don't think the statement works unless all four field are included. Two questions I seem to have. 1) Is it possible to create a null value with the macro language? 2) Does the statement on line 1387 work if one or more of the values is a null?
return ::WritePrivateProfileStringUTF8(data->getstr(1), data->getstr(2), data->getstr(3), data->getstr(4));

I have tried "", \n, 0, and -0 as null values. The zero became the value if my memory is any good.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: desga2
Date: June 25, 2009 08:19PM

In C++ you have NULL word to represent a null value but in K-Meleon Macro Language a null value is represented by an empty string "" or a 0 (zero).

I think this can work:
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, , $_ini_Demo_Path);

In C++ a NULL can be any value type; a number, a string, a pointer, ...
I think that in statement 1386: checkArgs(__FUNCTION__, data, 4);
only check the parameter number and possibly the type of these (usually a string, exactly a pointer to a string).

About cmd problem,, I think is the usual problem with double quotes in paths with spaces. Try this:

exec("cmd.exe /c del \"".$_ini_Demo_Path."\"");

K-Meleon in Spanish



Edited 1 time(s). Last edit at 06/25/2009 08:19PM by desga2.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 25, 2009 08:25PM

@ desga2

You were faster than I. It was the pesky quotes and special quotes. I found your post when I came here to post my change.
exec("cmd /c ERASE \"".$_ini_Demo_Path."\"");

I will go back and re-test the nulls. Thanks.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 25, 2009 08:37PM

@ desga2

This line
iniwrite($_ini_Demo_Section, $_ini_Demo_Item, , $_ini_Demo_Path);
causes problems in error console. Invalid expression ,$_ini_Demo_Path); and wrong number of arguments - expected 4 found 2.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 25, 2009 11:04PM

I have tried several methods to send a null value to the iniwrite statement. Sometimes I get a blank, perhaps a null, value but never does the statement remove the item from the section.
#$_ini_Demo_Value =  "";  ## No delete, the value becomes blank
#$_ini_Demo_Value =  -0;  ## No delete, the value becomes 0
#$_ini_Demo_Value =  \n;  ## No delete, the value becomes blank
#$_ini_Demo_Value =  \t;  ## No delete, the value becomes blank
$_ini_Demo_Value =    ;  ## No delete, the value becomes blank
Does anyone have another value that I can try?

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 26, 2009 12:43AM

Quote
desga2
In C++ you have NULL word to represent a null value but in K-Meleon Macro Language a null value is represented by an empty string "" or a 0 (zero).
The macro language empty string does not equate to the C++ NULL word when using iniwrite. Perhaps we need another macro language special string which could be \null. That may be too much like the \n for new line.

I have run out of things to try for a null value. Should I start a thread in the bugs section of the forum? Should I do a bug report?

Options: ReplyQuote
Re: macro command: writefile()
Posted by: mark307
Date: June 26, 2009 03:50PM

Quote
JujuLand
File testing or env reading must be present in mark307 utils kplugin.
Here are some examples to use utils kplugin in the macro.
# delete file.
pluginmsgex(utils, "exist", $_ini_Demo_Path, STRING) ? pluginmsg(utils, "unlink", $_ini_Demo_Path) : "";

# select shell and run.
$_cmd=pluginmsgex(utils, "GetOSVer", "Platform", STRING) == 2 ? "cmd.exe" : "command.com";
pluginmsgex(utils, "execex", $_cmd." /c del \"".$_ini_Demo_Path."\"", STRING);

# get environment variable.
alert(pluginmsgex(utils, "getenv", "PATH", STRING));
thanks.

Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 26, 2009 04:07PM

I have asked for a new special variable. \null, for the macro language.
http://kmeleonbrowser.org/forum/read.php?4,94189

I am posting the latest version of ini_Demo.kmm. I have changed the $_ini_Demo_Item variable name to $_ini_Demo_Key to make it consistent with the names for part of an ini file.

This version of the macro does not require Windows Scripting Host for the the ini file delete operation. Thank to Jujuland and degas2 for help on that.

Just saw Mark307's post. I will look into using that.

ini_Demo.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ini_Demo.kmm
# ---------- Valid for KM 1.5.3 ---------------
#
# Dependencies        : main.kmm
# Resources           : ini_Demo.ini
# Preferences         : -
# Version             : 0.6  6/26/09  JamesD 
# --------------------------------------------------------------------------------

_ini_Demo_RunCode{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Key = "Orange" ;
$_ini_Demo_Value = "Common" ;
alert($_ini_Demo_Path, "Proposed file name", INFO);
alert(" section name  ".$_ini_Demo_Section."\n item name      ".$_ini_Demo_Key."\n item value      ".$_ini_Demo_Value, "Proposed field values", INFO); 
iniwrite($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO); 
}

_ini_Demo_RunCode2{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Key = "Orange" ;
$_Value = "" ;
$_Value = iniread($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
alert($_Value, "item value", INFO);
$_Value==""?0:alert(readfile($_ini_Demo_Path), "The file as written", INFO);
}

_ini_Demo_RunCode3{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Key = "Orange" ;
#$_ini_Demo_Value =  "";  ## No delete, the value becomes blank
#$_ini_Demo_Value =  -0;  ## No delete, the value becomes 0
#$_ini_Demo_Value =  \n;  ## No delete, the value becomes blank
#$_ini_Demo_Value =  \t;  ## No delete, the value becomes blank
#$_ini_Demo_Value =    ;  ## No delete, the value becomes blank
#$_ini_Demo_Value = '\0'; ## No delete, the value becomes blank 
#$_ini_Demo_Value = \0 ;  ## No delete, the value becomes blank
#$_ini_Demo_Value = null; ## No delete, the value becomes 'null'
$_ini_Demo_Value = \null; ## No delete, the value becomes blank
iniwrite($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
$_Value = "" ;
$_Value = iniread($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
$_ini_Dtext1 = "As you can see, this does not delete \n" ;
$_ini_Dtext2 = "the line as expected.  The value for the \n " ;
$_ini_Dtext3 = "key, Orange, has been set equal to " ; 
alert($_ini_Dtext1.$_ini_Dtext2.$_ini_Dtext3.$_Value.".", "Delete Key", INFO);
}

_ini_Demo_RunCode4{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Key = "" ;
$_ini_Demo_Value =  "";
iniwrite($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
$_ini_Dtext1 = "As you can see, this does not delete \n" ;
$_ini_Dtext2 = "the section as expected.  The value for the \n " ;
$_ini_Dtext3 = "Key Orange is unchanged, and a new \n" ;
$_ini_Dtext4 = "key line has been created. " ;
alert($_ini_Dtext1.$_ini_Dtext2.$_ini_Dtext3.$_ini_Dtext4, "Delete Section", INFO);
}

_ini_Demo_RunCode5{
$_ini_Demo_Section = "Dictionary" ;
$_ini_Demo_Key = "Orange" ;
$_ini_Demo_Value = "Unique" ;
alert("This will change the value of key, Orange, to \"Unique\"");
iniwrite($_ini_Demo_Section, $_ini_Demo_Key, $_ini_Demo_Value, $_ini_Demo_Path);
alert(readfile($_ini_Demo_Path), "The file as written", INFO);
}

_ini_Demo_RunCode6{
exec("cmd /c ERASE \"".$_ini_Demo_Path."\"");
## For user of win9x operating systems, cmd should be replaced with Command in the above line 
}

_ini_Demo_BuildMenu{
	# add another option to Help menu
$_ini_Demo_Popm = "ini Demo Testing" ;
setmenu("KMDocs",popup,$_ini_Demo_Popm,3);
setmenu($_ini_Demo_Popm,"macro","Writing","_ini_Demo_RunCode");
setmenu($_ini_Demo_Popm,"macro","Reading","_ini_Demo_RunCode2");
setmenu($_ini_Demo_Popm,"macro","Delete item","_ini_Demo_RunCode3");
setmenu($_ini_Demo_Popm,"macro","Delete section","_ini_Demo_RunCode4");
setmenu($_ini_Demo_Popm,"macro","Overwrite item","_ini_Demo_RunCode5");
setmenu($_ini_Demo_Popm,"macro","Delete ini file","_ini_Demo_RunCode6");
}

_ini_Demo_GetPath{
## assumes that "ini_Demo.kmm" and "ini_Demo.js" are in UserMacroFolder
$_ini_Demo_Path=getfolder(UserMacroFolder)."\\ini_Demo.ini";
$_ini_Demo_JSpath =getfolder(UserMacroFolder)."\\ini_Demo.js";
}

# - - - - - - - - - - - - - - -
$OnStartup=$OnStartup."_ini_Demo_GetPath;";
$OnInit=$OnInit."_ini_Demo_BuildMenu;";
$macroModules=$macroModules."ini_Demo;";



Options: ReplyQuote
Re: macro command: writefile()
Posted by: JamesD
Date: June 26, 2009 07:16PM

I have updated MacroLanguage2 with some information about iniread and iniwrite. http://kmeleon.sourceforge.net/wiki/MacroLanguage2

Options: ReplyQuote
Re: macro command: writefile()
Posted by: desga2
Date: June 26, 2009 08:05PM

Thanks JamesD a good work. smiling smiley

K-Meleon in Spanish

Options: ReplyQuote


K-Meleon forum is powered by Phorum.