I hope this will help SkyFrontier with consolidating scripts the way he wants. Good luck with porting scripts to XYwiki.
What it does? See SkyFrontier's posts above.
Code: Select all
//ScriptTool
sub _assert;
global $g_ini;
self $g_ini, base;
$g_ini="<xyscripts>\$g_ini.ini";
getkey $lastextension, "lastext", "mru", $g_ini;
getkey $lastpath, "lastpath", "mru", $g_ini;
getkey $lastname, "lastname", "mru", $g_ini;
getkey $lastcamelcase, "lastCC", "mru", $g_ini;
getkey $lastfile, "lastfile", "mru", $g_ini;
$lasttext="";
getkey $lastansi, "lastansi", "mru", $g_ini;
getkey $lastuni, "lastuni", "mru", $g_ini;
$ScriptTool=<<<ScriptTool
<TABLE border=0>
<TR valign=middle>
<TD align=right valign=top>
<FORM NAME="ScriptTool" ACTION="xys: ">Extension:
</TD><p>
<TD><INPUT TYPE=TEXT VALUE="$lastextension" NAME="extension" size="5"><BODY onLoad="document.forms.ScriptTool.name.focus()">
</TD>
</TR>
<TR>
<TD align=right valign=top>Destination path:
</TD>
<TD><INPUT TYPE=TEXT VALUE="$lastpath" NAME="path" size="50">
</TD>
</TR>
<TR>
<TD align=right valign=top>Name:
</TD>
<TD><INPUT TYPE=TEXT VALUE="$lastname" NAME="name" size="20"><br>
<INPUT TYPE="checkbox" name="camelcase" value="1" $lastcamelcase> convert to CamelCase
</TD>
</TR>
<TR>
<TD align=right valign=top>Script:
</TD>
<TD><INPUT TYPE=radio name="encode" value="ASCII" $lastansi> <small>ASCII</small>
<INPUT TYPE=radio name="encode" value="UNICODE" $lastuni> <small>UNICODE</small>
</TD>
</TR>
<TR>
<TD>
</TD>
<TD><INPUT TYPE=SUBMIT STYLE=background:DFDFFF name="submit" value="Write">
<INPUT TYPE=SUBMIT STYLE=background:DFDFFF name="submit" value="Append">
<INPUT TYPE=SUBMIT STYLE=background:DFDFFF name="submit" value="View/Edit">
</FORM>
<TD>
</TR>
</TABLE>
ScriptTool;
$g_Tool = urldecode (html("$ScriptTool", 600, 350, "Script Tool"));
IF ($g_Tool==""){
status "Script closed.";
end 1==1;
}
$pathpos = strpos ($g_Tool, "&path=");
$namepos =strpos ($g_Tool, "&name=");
$encodepos =strpos ($g_Tool, "&encode=");
$submitpos =strpos ($g_Tool, "&submit=");
$extension= replace (gettoken($g_Tool, 1, "&path="), "?extension=","");
$path= gettoken($g_Tool, 1, "&name=");
$path = substr ($path, $pathpos+6);
$path= eval($path);
IF ($g_Tool Like "*camelcase*"){
setkey "checked", "lastCC", "mru", $g_ini;
$name= gettoken($g_Tool, 1, "&camelcase=");
$name = substr ($name, $namepos+6);
$name= replacelist($name, " a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z", "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z",",");
$first=substr($name,0,1);
$first=replacelist($first, "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z","A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,,Q,R,S,T,U,V,W,X,Y,Z",",");
$name=substr($name,1);
$name=$first.$name;
$camelcase=gettoken($g_Tool,4,"&");
$camelcase=gettoken($camelcase,2,"=");
}
ELSE{
$name= gettoken($g_Tool, 1, "&encode=");
$name = substr ($name, $namepos+6);
$camelcase="";
}
$encode= gettoken($g_Tool, 1, "&submit=");
$encode = substr ($encode, $encodepos+8);
$submit= substr ($g_Tool, $submitpos+8);
IF ($encode=="UNICODE"){
$mode="tu";
setkey "checked", "lastuni", "mru", $g_ini;
setkey "", "lastansi", "mru", $g_ini;
}
ELSE{
$mode="ta";
setkey "", "lastuni", "mru", $g_ini;
setkey "checked", "lastansi", "mru", $g_ini;
}
IF ($extension == ""){
msg "No extension provided!";
load self("file");
}
setkey $extension, "lastext", "mru", $g_ini;
IF ($path == ""){
msg "No path provided!";
load self("file");
}
setkey $path, "lastpath", "mru", $g_ini;
IF ($name == ""){
msg "No name provided!";
load self("file");
}
setkey $name, "lastname", "mru", $g_ini;
$lastfile= "$path$name.$extension";
setkey $lastfile, "lastfile", "mru", $g_ini;
$textfooter="<crlf><crlf>===============<crlf><crlf>";
$on_exist="o";
IF ($submit=="Append"){
$text="";
$edittext= input ("Append below text to $path$name.$extension Mode:$encode",,$text, m, "cancel",800,600);
IF($edittext=="cancel"){
load self("file");
}
$text="$textfooter $edittext";
$on_exist="a";
}
ELSEIF ($submit=="View/Edit"){
$lastext="";
IF (exists("$lastfile"=="1")){
$lasttext= readfile ("$lastfile");
}
$edittext= input ("View/Edit text $path$name.$extension Mode:$encode",,$lasttext, m, "cancel",800,600);
IF($edittext=="cancel"){
load self("file");
}
$text= $edittext;
}
ELSE {
$text="";
$edittext= input ("Write below text to $path$name.$extension Mode:$encode",,$text, m, "cancel",800,600);
IF($edittext=="cancel"){
load self("file");
}
$text= $edittext;
}
writefile ("$path$name.$extension", $text, $on_exist, $mode);
load self("file");
end(1==1);
"_assert : _assert"
$minimum = "9.40.0000";
$compatible = (compare(<xyver>, $minimum, v) == -1) ? 0 : 1;
assert ($compatible), "This script needs XYplorer version $minimum or higher.", 1;