PDA

View Full Version : Preview Help #2



GoOgLe
03-28-2007, 06:19 AM
http://img521.imageshack.us/img521/1755/erroryf5.png



strText = Input.GetText("Input1");-- get the text
-------------------------------------------------------------------------------------
strText = String.Replace(strText, "
", "<p align=right>", false);-- translate
strText = String.Replace(strText, "", "</p>", false);-- translate
strText = String.Replace(strText, "
", "<p align=center>", false);-- translate
strText = String.Replace(strText, "", "</p>", false);-- translate
strText = String.Replace(strText, "
", "<p align=left>", false);-- translate
strText = String.Replace(strText, "", "</p>", false);-- translate
strText = String.Replace(strText, "[color=", "<font color=", false);
strText = String.Replace(strText, "[/COLOR]", "</FONT>", false);-- translate
strText = String.Replace(strText, "[size=", "<font size=", false);
strText = String.Replace(strText, "[/SIZE]", "</FONT>", false);
strText = String.Replace(strText, "[font=", "<font face=", false);
strText = String.Replace(strText, "", "<ol>", false);-- translate
strText = String.Replace(strText, "", "</ol>", false);-- translate
strText = String.Replace(strText, " ", "<li>", false);-- translate
strText = String.Replace(strText, "", "<ul>", false);-- translate
strText = String.Replace(strText, "", "</ul>", false);-- translate
strText = String.Replace(strText, " ", "<li>", false);-- translate
strText = String.Replace(strText, "", "<b>", false);-- translate
strText = String.Replace(strText, "", "</b>", false);-- translate
strText = String.Replace(strText, "", "<i>", false);-- translate
strText = String.Replace(strText, "", "</i>", false);-- translate
strText = String.Replace(strText, "", "<u>", false);-- translate
strText = String.Replace(strText, "", "</u>", false);-- translate
strText = String.Replace(strText, "
", "<blockquote><P>", false);-- translate
strText = String.Replace(strText, "", "</P></blockquote>", false);-- translate
strText = String.Replace(strText, "[URL=", "<a href=", false);
strText = String.Replace(strText, "[/URL]", "</A>", false);
strText = String.Replace(strText, "[EMAIL=", "<a href=mailto:", false);
strText = String.Replace(strText, "[/EMAIL]", "</A>", false);
strText = String.Replace(strText, "", "<img src=", false);
strText = String.Replace(strText, "", ">", false);
strText = String.Replace(strText, "
", "<blockquote>", false);
strText = String.Replace(strText, "", "</blockquote>", false);
strText = String.Replace(strText, "
", "<PRE>", false);
strText = String.Replace(strText, "", "</PRE>", false);
strText = String.Replace(strText, "
", "<? ", false);-- translate
strText = String.Replace(strText, "", " ?>", false);-- translate
strText = String.Replace(strText, "[", "<", false);
strText = String.Replace(strText, "]", ">", false);
-----------------------------------------------------------------------------------------------------------
TextFile.WriteFromString("C:\\temp_preview.html","<HTML>"..strText.."</HTML>",false);-- write the html file
Web.LoadURL("Web1", "C:\\temp_preview.html");-- show the preview

i have that code on preview button but i cant make <br> can someone help please ???

RizlaUK
03-28-2007, 06:28 AM
use this :yes


strText = String.Replace(strText, "\r\n", "<br>", false);

GoOgLe
03-28-2007, 06:53 AM
thanks Rizlauk
there is only 1 word to say PERFECT

will u also helpme with color palette, font and size comboboxes please ??? likethe ones u have in ur project ...

GoOgLe
03-28-2007, 09:15 AM
@ RizlaUk

will u also helpme with color palette, font and size comboboxes please ??? like the ones u have in ur bbcoder v3 project ???

RizlaUK
03-28-2007, 09:43 AM
thay all work with the same code, near enough, with some minor adjustments

but, here goes anyway


Size combo

strText = Input.GetText(MainInput);
cPos=GetCaretPos(MainInput)
selString = Input.GetSelection(MainInput);
sel = ComboBox.GetSelected("co_size");
Size = ComboBox.GetItemData("co_size", sel);

cRow=GetCaretRow(MainInput)
if sel ~= 1 then
if selString ~= nil then
BeforSelection = String.Mid(strText, 0, selString.Start);
AfterSelection = String.Mid(strText, selString.End+1, -1);
sel = selString.End-selString.Start
Selection = String.Mid(strText, selString.Start, sel+1);
Input.SetText(MainInput, BeforSelection..""..Selection..""..AfterSelection);
Input.SetSelection(MainInput, selString.Start+8, selString.End+8);
Input.ScrollToLine("inp_main", cRow);
else
BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos, -1);
Input.SetText(MainInput, BeforCaret..""..AfterCaret);
Input.SetSelection(MainInput, cPos+9, cPos+8);
Input.ScrollToLine(MainInput, cRow);
end
end


Font Combo

strText = Input.GetText(MainInput);
cPos=GetCaretPos(MainInput)
selString = Input.GetSelection(MainInput);
sel = ComboBox.GetSelected("co_font");
Font = ComboBox.GetItemText("co_font", sel);
FontLength = String.Length(Font);
cRow=GetCaretRow(MainInput)
if sel ~= 1 then
if selString ~= nil then
BeforSelection = String.Mid(strText, 0, selString.Start);
AfterSelection = String.Mid(strText, selString.End+1, -1);
sel = selString.End-selString.Start
Selection = String.Mid(strText, selString.Start, sel+1);
Input.SetText(MainInput, BeforSelection..""..Selection..""..AfterSelection);
Input.SetSelection(MainInput, selString.Start+7+FontLength, selString.End+7+FontLength);
Input.ScrollToLine(MainInput, cRow);
else
BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos, -1);
Input.SetText(MainInput, BeforCaret..""..AfterCaret);
Input.SetSelection(MainInput, cPos+8+FontLength, cPos+7+FontLength);
Input.ScrollToLine(MainInput, cRow);
end
end

Color pallet- you will need worms color dialog plugin to make this work

tblColors = ColorDialog.Show(0)
cRow=GetCaretRow(MainInput)
if tblColors then
strText = Input.GetText(MainInput);
cPos=GetCaretPos(MainInput)
selString = Input.GetSelection(MainInput);
if selString ~= nil then
BeforSelection = String.Mid(strText, 0, selString.Start);
AfterSelection = String.Mid(strText, selString.End+1, -1);
sel = selString.End-selString.Start
Selection = String.Mid(strText, selString.Start, sel+1);
Input.SetText(MainInput, BeforSelection..""..Selection..""..AfterSelection);
Input.SetSelection(MainInput, selString.Start+15, selString.End+15);
Input.ScrollToLine(MainInput, cRow);
else
BeforCaret = String.Mid(strText, 1, cPos);
AfterCaret = String.Mid(strText, cPos, -1);
Input.SetText(MainInput, BeforCaret..""..AfterCaret);
Input.SetSelection(MainInput, cPos+16, cPos+15);
Input.ScrollToLine(MainInput", cRow);
end
end


after all this code iv given you i expect some credit in your final app, if not a check in the post, lol :p (in pounds, sterling plz ;) )