Can anyone support me to use this function?

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2015.01.01 08:55
 

Hi,

I really wanted to use this function written by "RaptorUK", but i am still getting error.

I am not expert with ObjectLabel, but i tried my best to display objects on screen, too much of line i wrote.

so i would like to use CommentLab

her eis the code:

void CommentLab(string CommentText)   
  {
   string CommentLabel;
   int CommentIndex = 0;
   
   if (CommentText == "")
      {
      //  delete all Comment texts
      while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
         {
         ObjectDelete(StringConcatenate("CommentLabel", CommentIndex ));
         CommentIndex++;
         }
      return;
      }
   
   while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
      {
      CommentIndex++;
      }
      
   CommentLabel = StringConcatenate("CommentLabel", CommentIndex);  
   ObjectCreate(CommentLabel, OBJ_LABEL, 0, 0, 0 );
   ObjectSet(CommentLabel, OBJPROP_CORNER, 0);
   ObjectSet(CommentLabel, OBJPROP_XDISTANCE, 5);
   ObjectSet(CommentLabel, OBJPROP_YDISTANCE, 15 + (CommentIndex * 15) );
   ObjectSetText(CommentLabel, CommentText, 10, "Tahoma", Status_Color );   
   
   }

I declared Status_Color as Global variable string

Please advice me to use the above function correctly. so that i can call this function as much as i want to use. currently i write line by line too much, so its lacking memory and speed.

Thanks in Advance.


avatar
9
evertonbg 2015.01.01 15:34 #
 

Hi, sheriffonline.

The right "Status_Color" global variable type is "color".

color Status_Color = clrRed;
avatar
273
sheriffonline 2015.01.01 16:52 #
 
evertonbg:

Hi, sheriffonline.

The right "Status_Color" global variable type is "color".

Thanks evetonbg. i declared "Status_Color" as you mentioned. but still shows 2 warnings?

warnings:

'CommentLab' - expression on global scope not allowed
Function "CommentLab" is not referenced and will be removed from exp-file

Code I used:

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables

color Status_Color = Red;


int init()
{
   
}

// Expert start
int start()
{
   
    
}



void CommentLab(string CommentText)
{
    string CommentLabel;
    int CommentIndex = 0;
       
    if (CommentText == "")
    {
        //  delete all Comment texts
        while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
        {
            ObjectDelete(StringConcatenate("CommentLabel", CommentIndex ));
            CommentIndex++;
        }
        return;
    }
       
    while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
    {
        CommentIndex++;
    }
          
    CommentLabel = StringConcatenate("CommentLabel", CommentIndex);  
    ObjectCreate(CommentLabel, OBJ_LABEL, 0, 0, 0 );
    ObjectSet(CommentLabel, OBJPROP_CORNER, 0);
    ObjectSet(CommentLabel, OBJPROP_XDISTANCE, 5);
    ObjectSet(CommentLabel, OBJPROP_YDISTANCE, 115 + (CommentIndex * 15) );
    ObjectSetText(CommentLabel, CommentText, 10, "Tahoma", Status_Color );   
       
}

CommentLab("This is testing");



int deinit()
{
    if (false) ObjectsDeleteAll();
  
}

No text displayed on chart while i run EA



avatar
735
honest_knave 2015.01.01 17:27 #
 

You really need to start googling some of your questions, as they have been asked many times.

Start by searching Google for "expression on global scope not allowed".

The warning: "Function "CommentLab" is not referenced and will be removed from exp-file" is fairly self-explanatory, but again a Google search of "is not referenced and will be removed from exp-file" will lead you to your solutions.


avatar
12985
WHRoeder 2015.01.02 16:22 #
 
honest_knave: You really need to start googling some of your questions, as they have been asked many times.
Or this
void CommentLab(string CommentText)
{
    :       
}

CommentLab("This is testing");  <<<< Expression on global scope

int deinit()
{
    :
}

avatar
273
sheriffonline 2015.01.04 13:05 #
 
WHRoeder:
honest_knave: You really need to start googling some of your questions, as they have been asked many times.
Or this

Thanks for everyone. I fixed and works well. even i did better option after dicussed here.

Here is the Code for CommentLab Function

void CommentLab(int CommentIndex,int Corner,int XDistance,int YDistance,color Color_Status,int Font_Size,string Font_Name,string CommentText)   
{
    string CommentLabel;
    
       
    if (CommentText == "")
    {
        //  delete all Comment texts
        return;
    }
       
          
    CommentLabel = StringConcatenate("CommentLabel", CommentIndex);  
    ObjectCreate(CommentLabel, OBJ_LABEL, 0, 0, 0 );
    ObjectSet(CommentLabel, OBJPROP_CORNER, Corner);
    ObjectSet(CommentLabel, OBJPROP_XDISTANCE, XDistance);
    ObjectSet(CommentLabel, OBJPROP_YDISTANCE, YDistance);
    ObjectSetText(CommentLabel, CommentText, Font_Size, Font_Name, Color_Status );     
       
}
Back to topics list  

To add comments, please log in or register