Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 23

Thread: need help

  1. #1
    Join Date
    Mar 2007
    Posts
    452

    Star need help

    Code:
    result1 = Input.GetText("Input1");
    result6 = Input.SetSelection("Input1", 1, -1);
    if result6 == "" then
    Dialog.Message("Notice", "error", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else
    undot = Input.GetText("Input1");
    cbsa1 = ComboBox.GetSelected("ComboBox4");
    cbsa = ComboBox.GetItemData("ComboBox4", cbsa1);
    Input.SetText("Input1", result1.."[color="..cbsa.."]"..result6.."[/color]");
    Input.SetText("Input6", "");
    end
    i tried this code but it didnt work, why??? i just want to color highlighted text in input6.... not all the text in input6.... can someone help please ???
    Attached Files

  2. #2
    Join Date
    Mar 2007
    Posts
    452
    help help help

  3. #3
    Join Date
    Mar 2007
    Posts
    452
    is it not possible with input object ????

  4. #4
    Join Date
    Mar 2007
    Posts
    452
    Rizlauk can u help me please ????

  5. #5
    Join Date
    May 2006
    Posts
    5,380
    ok, your on the right track, but you need to use input.getselected and not input.gettext, to get the text to be highlited

    also forget about the 2 inputs, it gets confusing to the user and its a waist of time (i know, i made that mistake 1st time round), use just 1 input and edit the text within it,

    you will need to translate the bbcode into html for it to preview, my bbcoder translation script had over 1400 lines of code so im not going to write it for you

    heres a little sample of how to add the tags to the text (this is for the bold tag)

    Code:
    --get the selected string position
    selString = Input.GetSelection("Input1");
    --get the whole text of the input
    strText = Input.GetText("Input1");
    -- get the text b4 the selection
    BeforSelection = String.Mid(strText, 0, selString.Start);
    -- get the text after the selection
    AfterSelection = String.Mid(strText, selString.End+1, -1);
    -- do a little math to get the ammount of charas selected
    sel = selString.End-selString.Start
    -- get the selected string text
    Selection = String.Mid(strText, selString.Start, sel+1);
    -- set the text back into the input with the bold tags inplace
    Input.SetText("Input1", BeforSelection..""..Selection..""..AfterSelection);
    like iv said b4, this project wasent easy, it took me 3 months to do and i still wasent 100% happy with the results


    heres a working example of the code above
    Last edited by RizlaUK; 02-01-2009 at 11:35 AM.
    Open your eyes to Narcissism, Don't let her destroy your life!!

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    but id say thanks coz you have prompted me to rewrite my bbcoder app, im sure with my experiance gained in the last year i can do a better job of it now
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Mar 2007
    Posts
    452

    Thumbs up

    thanks Rizlauk
    thats work perfect

    and if u want we can work together for the coder...
    just pm me if u want

  8. #8
    Join Date
    Mar 2007
    Posts
    452
    Rizlauk
    can u help me with color palet ???

  9. #9
    Join Date
    Mar 2007
    Posts
    452
    Code:
    selected = ComboBox.GetSelected("ComboBox3");
    if selected == 1 then
    cbc = ComboBox.GetItemData("ComboBox3", 1);
    selString = Input.GetSelection("Input1");
    strText = Input.GetText("Input1");
    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("Input1", BeforSelection.."[color=..cbc]"..Selection.."[/color]"..AfterSelection);
    end
    why the code doesnt work ???
    i get error:
    On Click, Line6: attempt to index global 'selString (a nill value)'
    Last edited by GoOgLe; 03-21-2007 at 03:13 PM.

  10. #10
    Join Date
    May 2006
    Posts
    5,380
    the code i posted was pretty raw and had no error checking

    you will need to add some "IF" and "ELSE" statments to handle any errors


    the error you are getting is because no text in the input is selected so "selString" is returning a error

    add a line "if selString ~= nil then"

    Code:
    selected = ComboBox.GetSelected("ComboBox3");
    if selected == 1 then
    cbc = ComboBox.GetItemData("ComboBox3", 1);
    selString = Input.GetSelection("Input1");
    if selString ~= nil then
    strText = Input.GetText("Input1");
    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("Input1", BeforSelection.."[color=..cbc]"..Selection.."[/color]"..AfterSelection);
    end
    end

    also, this is wrong

    Code:
    Input.SetText("Input1", BeforSelection.."[color=..cbc]"..Selection.."[/color]"..AfterSelection);
    change to this

    Code:
    Input.SetText("Input1", BeforSelection.."[color="..cbc.."]"..Selection.."[/color]"..AfterSelection);
    Open your eyes to Narcissism, Don't let her destroy your life!!

  11. #11
    Join Date
    May 2006
    Posts
    5,380
    Hey, how you getting on


    Heres a more stable code template for you, you will need Worm's Caret dll to make this code work, search the forum for it

    this is for the basic bbcode tags

    PHP Code:
    strText Input.GetText(MainInput);
    cPos=GetCaretPos(MainInput)
    selString Input.GetSelection(MainInput);
    if 
    selString ~= nil then
        
    -- some text is selected so add the tags aroung the selection
        BeforSelection 
    String.Mid(strText0selString.Start);
        
    AfterSelection String.Mid(strTextselString.End+1, -1);
        
    sel selString.End-selString.Start
        Selection 
    String.Mid(strTextselString.Startsel+1);
        
    Input.SetText(MainInputBeforSelection.."[B]"..Selection.."[/B]"..AfterSelection);
        --[[
    on this line you need to edit the numbers, [B]=,[LEFT]=,and so on 
        
    for each tag you createthis sets the cursor in the right place when the tag has been added]]
        
    Input.SetSelection(MainInputselString.Start+3selString.End+3);
    else
        -- 
    no text is selected so add the tags where the cursor is
        BeforCaret 
    String.Mid(strText1cPos);
        
    AfterCaret String.Mid(strTextcPos, -1);
        --[[ 
    same on this lineedit the numbers to suit the tag,
        
    you will have to play with it a little bit to get it right for each tag]]
        
    Input.SetText(MainInputBeforCaret.."[B][/B]"..AfterCaret);
        
    Input.SetSelection(MainInputcPos+4cPos+3);
    end 
    this is to get your lists up n running (NOTE: small bug in the code i cant track down, it leaves a single unrecognized character at the end of the string, if anyone could help with that id be greatful )

    PHP Code:
    strText Input.GetText(MainInput);
    cPos GetCaretPos(MainInput)

        
    BeforCaret String.Mid(strText1cPos);
        
    AfterCaret String.Mid(strTextcPos, -1);    
        
        
    count=1
        ListItem 
    Dialog.Input("Ordered List""Enter Item: 1"""MB_ICONNONE);
    if 
    ListItem ~= "" and ListItem ~= "CANCEL" then
        tbList 
    = {}
        
    Table.Insert(tbList1"\r\n[LIST=1]");
        
    Table.Insert(tbList2"[*]"..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(tbListtbCount"[*]"..ListItem);
            else
            break
            
    end
        end
        
        Table
    .Insert(tbListtbCount+1"[/LIST]");
        
    strList Table.Concat(tbList"\r\n"1TABLE_ALL);
        
    Input.SetText(MainInputBeforCaret..strList..AfterCaret);
        
    strCount String.Length(strList);
        
    reloc=cPos+strCount+1
        Input
    .SetSelection(MainInputrelocreloc+2);
    end 
    Last edited by RizlaUK; 03-21-2007 at 07:47 PM.
    Open your eyes to Narcissism, Don't let her destroy your life!!

  12. #12
    Join Date
    Mar 2007
    Posts
    452
    hi again Rizlauk

    it is going good but i want to ask u something... please c the attachment...
    after i block something from the input i want to change the color but when i click combobox to choose the color... blocked text goes to normal and it doesnt paste color code
    Attached Files

  13. #13
    Join Date
    May 2006
    Posts
    5,380
    i dont get it, it works for me, select the color from the combo, click the button and it adds the code

    if you want it to add the code when the combo is selected then move the code from the button to the combo on select event
    Open your eyes to Narcissism, Don't let her destroy your life!!

  14. #14
    Join Date
    Mar 2007
    Posts
    452
    i know it works like that but if u want to add the color code with button click after selection from input then it doesnt work...
    Last edited by GoOgLe; 03-22-2007 at 08:02 AM.

  15. #15
    Join Date
    Mar 2007
    Posts
    452
    and also whats wrong with this code ?? i dont need text selection with image adding and if dont select text code doesnt work

    image = Dialog.Input("WEB", "IMAGE:", "", MB_ICONQUESTION);
    if (image ~= "CANCEL") then
    selString = Input.GetSelection("Input1");
    if selString ~= nil then
    strText = Input.GetText("Input1");
    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("Input1", BeforSelection.."[IMG]"..image.."[/IMG]"..AfterSelection);
    end
    end
    Last edited by GoOgLe; 03-22-2007 at 08:12 AM.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts