10 Sep 2011 01:01
hola miren soy nuevo aqui y en ams y pues me descargue ya tiempos una apz de una hoja de calculo con la funcion sumar y pues no se como lograr hacer que reste y queria ver si uestedes los master en ams me pueden dar una mano aqui dejo la apz espero me puedan ayudar y gracias por leer al menos mi post
funcion en la Grid1
a la funcion de suma la he dejado como comentario y abajo coloque la que yo estoy intentando hacer funcionar.
aqui les dejo la apz para que vean como esta todo el script y ver si me pueden ayudar.
dejo el script de la funcion de suma:
ahora el que yo intento modificar para que reste:
funcion en la Grid1
a la funcion de suma la he dejado como comentario y abajo coloque la que yo estoy intentando hacer funcionar.
aqui les dejo la apz para que vean como esta todo el script y ver si me pueden ayudar.
Código: Seleccionar todo
http://www.mediafire.com/?fgw78ykh4k0mvbb
dejo el script de la funcion de suma:
local isFormula = Grid.GetCellText("Grid1", e_Row, e_Column);
local Title = Grid.GetCellText("Grid1", 0, e_Column)
local Kow = Grid.GetCellText("Grid1", e_Row, 0)
local equal = String.Left(isFormula, 1);
if equal == "=" then
local st = String.Find(e_NewText, "(", 1, false);
if st == -1 then
local sLen = String.Length(isFormula);
local sCopyFrom = String.Right(isFormula, sLen-1);
local sCopyFrom = String.Upper(sCopyFrom);
local sToCopy = Names[sCopyFrom][3]
Coord = Title..Kow;
local sCToCopy = Grid.GetCellText("Grid1", Names[sCopyFrom][1], Names[sCopyFrom][2]);
Names[Coord][3] = isFormula
Grid.SetCellText("Grid1", nCurRow, nCurCol, sCToCopy, true);
Input.SetText("Input1", isFormula);
else
local en = String.ReverseFind(e_NewText, ")", false);
if st == 2 then
else
sFormula = String.Mid(e_NewText, 2, st-2);
if sFormula == "suma" or sFormula == "SUMA" or sFormula == "SUM" or sFormula == "sum" then
local md = String.Find(e_NewText, ":", st, false);
local sum = 0;
local sFrom = String.Mid(e_NewText, st+1, md-st-1);
local sFrom = String.Upper(sFrom);
local sTo = String.Mid(e_NewText, md+1, en-md-1);
local sTo = String.Upper(sTo);
local rowPlus = Names[sTo][1]-Names[sFrom][1]
local cel = 0;
if rowPlus <= 0 then
local colPlus = Names[sTo][2] - Names[sFrom][2]
if colPlus <= 0 then
--Error
else
for x=1, (colPlus+1) do
sum = sum + (String.ToNumber(Grid.GetCellText("Grid1", Names[sFrom][1], Names[sFrom][2]+cel)))
cel = cel + 1;
end
end
else
for x=1, (rowPlus+1) do
sum = sum + (String.ToNumber(Grid.GetCellText("Grid1", Names[sFrom][1]+cel, Names[sFrom][2])))
cel = cel + 1
end
end
Coord = Title..Kow;
Names[Coord][3] = isFormula;
Grid.SetCellText("Grid1", e_Row, e_Column, sum, true);
Input.SetText("Input1", Names[Coord][3]);
sum = nil;
end
end
end
elseif Kow ~= "" and Kow ~= nil then
Coord = Title..Kow;
Names[Coord][3] = isFormula;
Input.SetText("Input1", Names[Coord][3]);
end
if isFormula ~= "" then
if tblGrid then
wegot = false;
if (Table.Count(tblGrid)) == 0 then
Table.Insert(tblGrid, 1, {Coord,isFormula});
clHash = false;
else
for x=1, (Table.Count(tblGrid)) do
if tblGrid[x][1] == Coord then
tblGrid[x][2] = isFormula;
wegot = true;
clHash = false;
break;
end
end
if wegot == false then
Table.Insert(tblGrid, (Table.Count(tblGrid))+1, {Coord,isFormula});
clHash = false;
end
end
end
else
Input.SetText("Input1", Names[Coord][3]);
for x=1, (Table.Count(tblGrid)) do
if tblGrid[x][1] == Coord then
Table.Remove(tblGrid, x);
clHash = false;
break;
end
end
if (Table.Count(tblGrid)) == 0 then
if (Table.Count(tblGrid2)) == 0 then
clHash = true;
end
end
end
local isFormula = Grid.GetCellText("Grid1", e_Row, e_Column);
local Title = Grid.GetCellText("Grid1", 0, e_Column)
local Kow = Grid.GetCellText("Grid1", e_Row, 0)
local equal = String.Left(isFormula, 1);
if equal == "=" then
local st = String.Find(e_NewText, "(", 1, false);
if st == -1 then
local sLen = String.Length(isFormula);
local sCopyFrom = String.Right(isFormula, sLen-1);
local sCopyFrom = String.Upper(sCopyFrom);
local sToCopy = Names[sCopyFrom][3]
Coord = Title..Kow;
local sCToCopy = Grid.GetCellText("Grid1", Names[sCopyFrom][1], Names[sCopyFrom][2]);
Names[Coord][3] = isFormula
Grid.SetCellText("Grid1", nCurRow, nCurCol, sCToCopy, true);
Input.SetText("Input1", isFormula);
else
local en = String.ReverseFind(e_NewText, ")", false);
if st == 2 then
else
sFormula = String.Mid(e_NewText, 2, st-2);
if sFormula == "resta" or sFormula == "RESTA" or sFormula == "SUBTRACT" or sFormula == "subtract" then
local md = String.Find(e_NewText, ":", st, false);
local resta = 0;
local sFrom = String.Mid(e_NewText, st+1, md-st-1);
local sFrom = String.Upper(sFrom);
local sTo = String.Mid(e_NewText, md+1, en-md-1);
local sTo = String.Upper(sTo);
local rowResta = Names[sTo][1]-Names[sFrom][1]
local cel = 0;
if rowResta <= 0 then
local colResta = Names[sTo][2] - Names[sFrom][2]
if colResta <= 0 then
--Error
else
for x=1, (colResta-1) do
resta = resta - (String.ToNumber(Grid.GetCellText("Grid1", Names[sFrom][1], Names[sFrom][2]-cel)))
cel = cel - 1;
end
end
else
for x=1, (rowResta-1) do
resta = resta -(String.ToNumber(Grid.GetCellText("Grid1", Names[sFrom][1]-cel, Names[sFrom][2])))
cel = cel - 1
end
end
Coord = Title..Kow;
Names[Coord][3] = isFormula;
Grid.SetCellText("Grid1", e_Row, e_Column, resta, true);
Input.SetText("Input1", Names[Coord][3]);
resta = nil;
end
end
end
elseif Kow ~= "" and Kow ~= nil then
Coord = Title..Kow;
Names[Coord][3] = isFormula;
Input.SetText("Input1", Names[Coord][3]);
end
if isFormula ~= "" then
if tblGrid then
wegot = false;
if (Table.Count(tblGrid)) == 0 then
Table.Insert(tblGrid, 1, {Coord,isFormula});
clHash = false;
else
for x=1, (Table.Count(tblGrid)) do
if tblGrid[x][1] == Coord then
tblGrid[x][2] = isFormula;
wegot = true;
clHash = false;
break;
end
end
if wegot == false then
Table.Insert(tblGrid, (Table.Count(tblGrid))+1, {Coord,isFormula});
clHash = false;
end
end
end
else
Input.SetText("Input1", Names[Coord][3]);
for x=1, (Table.Count(tblGrid)) do
if tblGrid[x][1] == Coord then
Table.Remove(tblGrid, x);
clHash = false;
break;
end
end
if (Table.Count(tblGrid)) == 0 then
if (Table.Count(tblGrid2)) == 0 then
clHash = true;
end
end
end