LabWindows/CVI Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
40tude2

Two more options for the Edit/Format File or Edit/Format Selection

Status: New

First of all : I LOVE the Format File and Format Selection and many thanks for the existing options in the dialog box (pointer for example)

 

Here is what I propose :

 

1 - "Function calls on single line" check box in the Miscellenaous section of the dialog box so that :

 

int CVICALLBACK ScaleIt (int panel, int control, int event, void *callbackData,
                         int eventData1, int eventData2)
{
    int val;
    
    if (event == EVENT_COMMIT)
        {
        GetCtrlVal (panel, control, &val);
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_YAXIS,
                          VAL_RIGHT_YAXIS);   
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_YMAP_MODE, val);
        SetActiveCtrl (panel, PANEL_GRAPH);
        }
    return 0;
}

 The code above comes from ..\CVI2013\samples\userint\2yaxis.prj

 

Is transformed in :

 

int CVICALLBACK ScaleIt (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int val;
    
    if (event == EVENT_COMMIT)
        {
        GetCtrlVal (panel, control, &val);
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);   
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_YMAP_MODE, val);
        SetActiveCtrl (panel, PANEL_GRAPH);
        }
    return 0;
}

 

Please note this apply not only to the SetCtrlAttribute() function call but also to the ScaleIt() function itself (very first line)
A long time ago it was OK to restrict ourselves to 80 chars per line but today I feel more confortable with statements on one line

 

2 - "Insert empty line before first statement in function definition" check box in the Miscellenaous section of the dialog box
Especially usefull when you use the Java Formating Option where the '{' is at the end of the line


With the previous sample code :

 

int CVICALLBACK ScaleIt (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    int val;
    
    if (event == EVENT_COMMIT)
        {
        GetCtrlVal (panel, control, &val);
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);   
        SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_YMAP_MODE, val);
        SetActiveCtrl (panel, PANEL_GRAPH);
        }
    return 0;
}

 

The formated source (Java) should be :

 

int CVICALLBACK ScaleIt (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) {
  
  int val;

  if (event == EVENT_COMMIT) {
    GetCtrlVal (panel, control, &val);
    SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);
    SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_YMAP_MODE, val);
    SetActiveCtrl (panel, PANEL_GRAPH);
  }
  return 0;
}

 

Instead of : 

 

int CVICALLBACK ScaleIt (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) {
  int val;

  if (event == EVENT_COMMIT) {
    GetCtrlVal (panel, control, &val);
    SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);
    SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_YMAP_MODE, val);
    SetActiveCtrl (panel, PANEL_GRAPH);
  }
  return 0;
}

 

Pay attention to the "int val;" declaration with one spacing line in the first code and no spacing line in the second one.

 

Best regards, Philippe