-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_all_values.ulp
129 lines (122 loc) · 2.54 KB
/
show_all_values.ulp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Author: sansil, [email protected]
// Date: 16/10/16
/*
* Description:
* If you are soldering your components manually this ULP will help you.
* Highlight all the components with the same value on the board.
*/
// #usage just run "run show_all_values <value_to_find>" in command line
int count = 0;
string c = "0";
string s = "";
string valor = "";
string input_text = "";
string info = "";
string commandstring = ";WINDOW FIT;SHOW @ ";
//Control de entrada. se pasa el valor ingresado a lowercase. y se quitan los espacios. A los espacios los toma como un argc
string valorlow = "";
string inputString = "";
int j = 0;
char ch;
//output("C:log.txt","wt") {
for (int i = 1; i <= argc; i++)
{
inputString = argv[i];
j = 0;
valorlow = "";
while (inputString[j])
{
if (isalpha(inputString[j]))
{
ch = inputString[j];
valorlow[j] = tolower(ch);
}
else
{
valorlow[j] = inputString[j];
}
j++;
}
//printf("%s ",valorlow);
valor = valor + valorlow;
}
//printf("%s ",valor);
//}
//valor = valorlow;
if (argc <= 1)
{ // no ingreso el valor a buscar
dlgDialog("Info"){
dlgVBoxLayout{
dlgLabel("&Ingrese el valor de los commponentes a buscar");
dlgStringEdit(input_text);
dlgPushButton("+OK") dlgAccept();
//dlgPushButton("Cancel") dlgReject();
}
}
;
}
if (sheet)
{
sheet(S)
{
//output("C:log.txt","wt") {
if (input_text != "")
valor = input_text;
S.parts(P) if (P.value == valor)
{
//printf("%s ", P.name);
s = s + P.name + " ";
count++;
//printf(input_text);
}
//}
dlgDialog("Info")
{
sprintf(c, "%d", count);
string info = "Numero de componentes encontrados: " + c;
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
commandstring = commandstring + s;
exit(commandstring);
}
}
else if (board)
{
if (input_text != "")
valor = input_text;
board(B)
{
//output("C:log.txt","wt") {
B.elements(E)
{
//printf("%s ", E.value);
if (E.value == valor)
{
//printf("%s ", E.name);
s = s + E.name + " ";
count++;
//printf(input_text);
}
}
//}
dlgDialog("Info")
{
sprintf(c, "%d", count);
string info = "Numero de componentes encontrados: " + c;
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
commandstring = commandstring + s;
exit(commandstring);
}
}
else
{
int Result = dlgDialog("Info")
{
info = "Debe ejecutar el ULP dentro de un .SCH o .BRD";
dlgLabel(info);
dlgPushButton("+OK") dlgAccept();
};
}