Schrift
[thread]12873[/thread]

Inhalt einer vom User hochgeladenen Textdatei in einer Listbox anzeigen (Seite 2)

Leser: 1


<< |< 1 2 >| >> 16 Einträge, 2 Seiten
renee
 2008-12-10 18:14
#117059 #117059
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Du benutzt exakt den Quellcode, der im Wiki-Artikel angegeben ist?
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Newbie2008
 2008-12-10 18:21
#117060 #117060
User since
2008-12-05
26 Artikel
BenutzerIn
[default_avatar]
Ich habe die Funktion gerade noch einmal herauskopiert und eingefügt.
Skript läuft, aber die Fehlermeldungen werden nicht ausgegeben.

Hast du eine Idee?
renee
 2008-12-10 19:00
#117061 #117061
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Zeig bitte mal den Code, den Du benutzt (ganzes Skript).
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Newbie2008
 2008-12-10 20:39
#117063 #117063
User since
2008-12-05
26 Artikel
BenutzerIn
[default_avatar]
Code (perl): (dl )
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
#!/usr/bin/perl -w
use strict;
use Tk;

my %variable;
my $haupt = MainWindow->new();
frame ($haupt,%variable);
MainLoop;


sub frame {
        my ($haupt,%hash) = @_;

        my $frame_eingabe       = $haupt->Frame()->pack();
        my $frame_ausgabe       = $haupt->Frame()->pack();
        my $frame_button        = $haupt->Frame()->pack();
        my $frame_edit          = $haupt->Frame()->pack();

        my $Label_eingabe = $frame_eingabe->Label(
                -text =>'Bitte wählen Sie Ihre Ausgangs-Textdatei (txt):',
                )->pack(-side =>'left');

        my $Entry_eingabe = $frame_eingabe->Entry(
                -textvariable => \$hash{input},
        )->pack(-side => 'left');

        my $Button_eingabe = $frame_eingabe->Button(
                -text =>'Durchsuchen',
                -command => [\&eingabe, $haupt,\$hash{input}],
                )->pack(-side =>'left');



    my $Nachricht_lbl  = $frame_edit->Label(
                                -textvariable => \$hash{nachricht},
                                           )->pack();
    my $listbox = $frame_edit->Listbox(
                                -width    => 75,
                                -height   => 20,
                                             )->pack();


        my $Label_ausgabe = $frame_ausgabe->Label(
                -text =>'Unter welchem Namen / wo soll die Ausgabe-Textdatei gespeichert werden:',
                )->pack(-side =>'left');

        my $Entry_ausgabe = $frame_ausgabe->Entry(
                -textvariable => \$hash{output},
                )->pack(-side =>'left');

        my $Button_ausgabe = $frame_ausgabe->Button(
                -text =>'Durchsuchen',
                -command => [\&ausgabe, $haupt,\$hash{output}],
                )->pack(-side =>'left');


    my $Button_start = $frame_button->Button(
                                -text    => 'Ausfuehren',
                                -command => [\&einlesen,$listbox,\%hash])->pack();
}


sub einlesen {
    my ($list,$hashref) = @_;
    
    if(defined $hashref->{input} && defined $hashref->{output}){
        if(open(my $fh,'<',$hashref->{input}) && 
           open(my $w_fh,'>',$hashref->{output})){
            while(my $line = <$fh>){
                print $w_fh $. . " " . $line;
                chomp $line;
                $list->insert('end', $. . " " . $line);
            }
            close $fh;
            close $w_fh;
            $hashref->{message} = 'Aktion erfolgreich';
        }
        else{
            $hashref->{message} = 'Aktion nicht erfolgreich';
        }
    }
    else{
        $hashref->{message} = 'Bitte Eingabe- und Ausgabedatei festlegen';
    }
}


sub eingabe{
    my ($haupt,$var_ref) = @_;    
    my $Dateityp = [['Text files','.txt'],['Text files','.TXT']];
    $$var_ref = $haupt->getOpenFile(-filetypes => $Dateityp);
}

sub ausgabe{
    my ($haupt,$var_ref) = @_;
    my $Dateityp = [['Text files','.txt'],['Text files','.TXT']];
    $$var_ref = $haupt->getSaveFile(-filetypes => $Dateityp);
}
Gast Gast
 2008-12-10 22:18
#117068 #117068
Vergleiche mal Zeile 35 mit 76,79,83, was fällt da auf...
Newbie2008
 2008-12-11 00:29
#117073 #117073
User since
2008-12-05
26 Artikel
BenutzerIn
[default_avatar]
UAHRR - tausend Dank - welch dummer Fehler
<< |< 1 2 >| >> 16 Einträge, 2 Seiten



View all threads created 2008-12-07 16:20.