Thread: Formatting multiple text titles

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    3

    Formatting multiple text titles

    Hello forum,


    I’ve been tinkering around with a program written to run on mt4 (metatrader 4) which is based on C.


    I’m trying to change the format of a few titles i.e. “Position X”, “Position Y” and “Position Z”, but can only get it to work changing the format of one title (Position X) as follows:

    Code:
    void Display(string text)
     {
       string lab_str="EA-"+IntegerToString(DisplayCount);
       double ofset=0;
    
       string _str="";
       if (StringFind(text,"Position X",0)>=0)
       {
       ObjectSetText(lab_str,text,fontSise,fontName+" Bold",clrYellow);
       }else ObjectSetText(lab_str,text,fontSise,fontName,colour);   
      }

    Any thoughts as to how i can add “Position Y” and “Position Z” to the above so that they format the same please?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,974
    So

    if (StringFind(text,"Position Y",0)>=0)

    Doesn't work?

    What debug can you add to track the value of the text input parameter?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2019
    Posts
    3
    Yes, substituting "Position Y" for "Position X" in the original code works but how would I combine all so that X, Y and Z are all formatted within the code?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,974
    *shrug*
    Code:
       if (StringFind(text,"Position X",0)>=0)
       {
          ObjectSetText(lab_str,text,fontSise,fontName+" Bold",clrYellow);
       }
       else if (StringFind(text,"Position Y",0)>=0)
       {
          ObjectSetText(lab_str,text,fontSise,fontName+" Bold",clrYellow);
       }
       else if (StringFind(text,"Position Z",0)>=0)
       {
          ObjectSetText(lab_str,text,fontSise,fontName+" Bold",clrYellow);
       }
       else
          ObjectSetText(lab_str,text,fontSise,fontName,colour);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2019
    Posts
    3
    Hello Salem, thank you for your reply. Unfortunately it doesn't seem that straight forward as tried this method and it still doesn't work as in doesn't load.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,974
    > it still doesn't work as in doesn't load.
    What does that mean?

    Do you get error messages from some verification / compilation step?

    Another way.
    Code:
    if (StringFind(text,"Position X",0)>=0 ||
        StringFind(text,"Position Y",0)>=0 ||
        StringFind(text,"Position Z",0)>=0)
    {
       ObjectSetText(lab_str,text,fontSise,fontName+" Bold",clrYellow);
    }
    else
       ObjectSetText(lab_str,text,fontSise,fontName,colour);
    > I’ve been tinkering around with a program written to run on mt4 (metatrader 4) which is based on C.
    There are a lot of things based on C (or took some inspiration).
    List of C-family programming languages - Wikipedia

    Do you have a language reference we could look at?

    I notice that you posted on the C# forum.
    A language who's only relationship to C and C++ is in the choice of alphabet letter for it's name.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text formatting
    By newn in forum C++ Programming
    Replies: 6
    Last Post: 05-31-2012, 05:33 AM
  2. Help with formatting text
    By C89 in forum C Programming
    Replies: 10
    Last Post: 03-15-2012, 11:54 PM
  3. Help formatting text in c
    By anonymoususer in forum C Programming
    Replies: 3
    Last Post: 11-06-2011, 02:30 PM
  4. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  5. need help with formatting text
    By Flikm in forum C++ Programming
    Replies: 1
    Last Post: 09-06-2001, 07:52 PM

Tags for this Thread