PDA

View Full Version : Input Undo - Redo Help


GoOgLe
03-23-2007, 04:47 PM
is it possible to undo and redo for input object ???

Input.Undo("Input1");

this code doesnt undo when i add code

RizlaUK
03-23-2007, 06:02 PM
Input.Undo has always worked for me, how are you useing it, are you sure its assigned to the right input object

GoOgLe
03-24-2007, 04:40 AM
it works for me too when i type something but if i add a code to the text i wrote it doesnt work...

example:

works : google

doesnt work : google or google or any other code

GoOgLe
03-24-2007, 11:08 AM
is it possible with ams or i am wasting time ?????

RizlaUK
03-24-2007, 12:11 PM
works : google

doesnt work : google or google or any other code

i think thats because there was no actual keystroke in the input object, try useing worms keystroke dll to force a keystroke while the code is being added.....it might work....it might not

GoOgLe
03-24-2007, 12:14 PM
will u help me with ordered and unordered list Rizlauk ???

RizlaUK
03-24-2007, 01:36 PM
ok, heres my code,

orderd list
strText = Input.GetText(MainInput);
cPos = GetCaretPos(MainInput)

BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos+1, -1);

count=1
ListItem = Dialog.Input("Ordered List", "Enter Item: 1", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
tbList = {}
Table.Insert(tbList, 1, "\r\n");
Table.Insert(tbList, 2, " "..ListItem);

while (ListItem ~= "") do
count=count+1
ListItem = Dialog.Input("Ordered List", "Enter Item: "..count.." , Leave Blank or Click Cancel To End The List", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
tbCount = Table.Count(tbList);
tbCount=tbCount+1
Table.Insert(tbList, tbCount, " "..ListItem);
else
break
end
end
if tbCount == nil then
tbCount=2
end
Table.Insert(tbList, tbCount+1, "");
strList = Table.Concat(tbList, "\r\n", 1, TABLE_ALL);
Input.SetText(MainInput, BeforCaret..strList..AfterCaret);
strCount = String.Length(strList);
reloc=cPos+strCount+1
Input.SetSelection(MainInput, reloc, reloc+2);
Input.SetText("Input1", strCount);
end


unorderd list
strText = Input.GetText(MainInput);
cPos = GetCaretPos(MainInput)

BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos+3, -1);

count=1
ListItem = Dialog.Input("Ordered List", "Enter Item: 1", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
tbList = {}
Table.Insert(tbList, 1, "\r\n");
Table.Insert(tbList, 2, " "..ListItem);
while (ListItem ~= "") do
count=count+1
ListItem = Dialog.Input("Unordered List", "Enter Item: "..count.." , Leave Blank or Click Cancel To End The List", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
unCount = Table.Count(tbList);
unCount=unCount+1
Table.Insert(tbList, unCount, " "..ListItem);
else
break
end
end
if unCount == nil then
unCount=2
end
Table.Insert(tbList, unCount+1, "");
strList = Table.Concat(tbList, "\r\n", 1, TABLE_ALL);
Input.SetText(MainInput, BeforCaret..strList..AfterCaret);
strCount = String.Length(strList);
reloc=cPos+strCount+1
Input.SetSelection(MainInput, reloc, reloc+2);
Input.SetText("Input1", strCount);

end

GoOgLe
03-24-2007, 01:55 PM
do i have to cahnge all maininputs to input1 ????? when i change like that then it puts a number in input1 why ???

strText = Input.GetText("Input1");
cPos = GetCaretPos("Input1")

BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos+3, -1);

count=1
ListItem = Dialog.Input("Ordered List", "Enter Item: 1", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
tbList = {}
Table.Insert(tbList, 1, "\r\n");
Table.Insert(tbList, 2, " "..ListItem);
while (ListItem ~= "") do
count=count+1
ListItem = Dialog.Input("Unordered List", "Enter Item: "..count.." , Leave Blank or Click Cancel To End The List", "", MB_ICONNONE);
if ListItem ~= "" and ListItem ~= "CANCEL" then
unCount = Table.Count(tbList);
unCount=unCount+1
Table.Insert(tbList, unCount, " "..ListItem);
else
break
end
end
if unCount == nil then
unCount=2
end
Table.Insert(tbList, unCount+1, "");
strList = Table.Concat(tbList, "\r\n", 1, TABLE_ALL);
Input.SetText("Input1", BeforCaret..strList..AfterCaret);
strCount = String.Length(strList);
reloc=cPos+strCount+1
Input.SetSelection("Input1", reloc, reloc+2);
Input.SetText("Input1", strCount);

end
and if i dont change the input names then i get this error

RizlaUK
03-24-2007, 02:18 PM
delete that line off the end

" Input.SetText("Input1", strCount); "

i was useing that for the overall post length, its not needed, my test object was called input1, look at the code, the last 2 lines you are setting the text twice

strList = Table.Concat(tbList, "\r\n", 1, TABLE_ALL);
Input.SetText("Input1", BeforCaret..strList..AfterCaret);
strCount = String.Length(strList);
reloc=cPos+strCount+1
Input.SetSelection("Input1", reloc, reloc+2);
Input.SetText("Input1", strCount); --DELETE THIS LINE

dude, if you are not taking the time to even look at the code then im afraid you are not going to get very far with this or any other project

remember, this code is stright from my project, you will have to edit the names to suit your project

and as for the error you posted, line 1 arg 1 must be a string, relates to the name of your input object on line 1, check your code

GoOgLe
03-24-2007, 02:24 PM
that worked Rizlauk Thanks and sorry
i changed the input names but i got error again thats why i tried without changing the name... but i got error again

RizlaUK
03-24-2007, 02:33 PM
it pays, when someone gives you code to take a little time to examin it line by line (as thats what i do) as most of the time code is from someones project/example and can contain lines of code that were only there for testing or typed out at the forum and contains a small typo that the forum isent able to pick up on like ams dose, and most of the time the code is incompatable with your project with out minor editing

that way you get a little understanding of how it works and makes it easy to reproduce at a later time

but anyway, glad you got it working :yes

GoOgLe
03-29-2007, 08:30 AM
can someone help me please ???

Input.Redo("Input1");

Input.Undo("Input1");