File: ex-input-file.ulp

package info (click to toggle)
eagle 4.16-5
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 36,508 kB
  • sloc: sh: 82; makefile: 32
file content (75 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (6)
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
#usage "<b>Example: Input file dialog</b>\n"
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

string cmd = "";
int n = 0;        // global counter
char b[];
string fileName = "";

fileName = dlgFileOpen("Select a File", "");
int nBytes = fileread(b, fileName);

  for (n; n < nBytes; n++) {
     switch (b[n]) {
         case    0:  break;

         case    1:  cmd += "Device\n";
                     break;

         case    2:  cmd += "\nEND - HEADER\n";
                     break;

         case    3:  cmd += "\nEND - 3\n";
                     break;

         case    4:  cmd += "4";
                     break;

         case    5:  break;

         case    6:  break;

         case    7:  break;

         case    8:  break;

         case    9:  cmd += "<tab>\t";
                     break;


         case   10:  cmd += "Line Feed\n";
                     break;

         case   12:  cmd += "\nNew Page\n";
                     break;

         case   13:  cmd += "Carriage Return\n";
                     break;

         case   27:  cmd += "\nEscape\n";
                     break;

         case   32:  cmd += ".space." + b[n];
                     break;

         default:    cmd += b[n];
                     break;
         }
      }
   // Demo Text Editor Box
   dlgDialog("Text Editor Box") {
      dlgTextEdit(cmd);
      dlgHBoxLayout {
         dlgPushButton("+Ok") {
            dlgAccept();
            output("test.txt", "wt") {
               printf(cmd);
               }
            };
         dlgPushButton("-Cancel") dlgReject();
         }
      };
   exit(0);