Hi,

I've been working on a program for sometime now and while working on the finishing part I receive an error while trying to display text that I retrieved from a Text widget.

I have ten text fields and all of them work on having their contents retrieved and displayed from them except one which is exactly the same as the others. I've checked it a million times.. It's kind of hard to explain the whole situation so I cut down the program and made a new one based just on that area. I'm also using ActivePerl 5.6.1 (Build 633) on Windows XP.

use Tk; use strict; use warnings; #--- Variables--- my $program_title = "TESTING"; my $admission_1_value; my $admission_2_value; my $admission_3_valu +e; my $admission_4_value; my $admission_5_value; my $admission_6_value; my $ +admission_7_value; my $admission_8_value; my $admission_9_value; my $admission_10_value; +my $charge_1_value; my $charge_2_value; my $charge_3_value; my $charge_4_value; my $charge +_5_value; my $charge_6_value; my $charge_7_value; my $charge_8_value; my $charge_9_ +value; my $charge_10_value; #--- Define Main Window --- my $main_window = MainWindow->new(); $main_window->configure(-background=>'#FFFFFF'); $main_window->title("$program_title"); $main_window->minsize(qw(250 450)); $main_window->geometry('+325+150'); #--- Start Bottom Processing Field my $frame_process = $main_window->Frame(-background=>'#FFFFFF')->p +ack(side=>'bottom'); $frame_process->Button( -text=>'Process', -command=>\&PROCESS)->pack(side=>'top'); #--- Start Admission Fields --- my $frame_names = $main_window->Frame(-background=>'#FFFFFF')->pac +k(side=>'left'); my $admission_10 = $frame_names->Text(-width=>20,-height=>1)->p +ack(side=>'bottom'); $frame_names->Label(-text=>'Admission # 10', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_9 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 9', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_8 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 8', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_7 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 7', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_6 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 6', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_5 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 5', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_4 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 4', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_3 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 3', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_2 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 2', + -background=>'#FFFFFF')->pack(side=>'bottom'); my $admission_1 = $frame_names->Text(-width=>20,-height=>1)->pack( +side=>'bottom'); $frame_names->Label(-text=>'Admission # 1', + -background=>'#FFFFFF')->pack(side=>'bottom'); #--- BLANK COLUMN my $frame_blank5 = $main_window->Frame(-background=>'#FFFFFF')- +>pack(side=>'left'); $frame_blank5->Label(-text=>' ', -background=>'#FFFFFF')->pack(side=>'bottom'); #---Start Charge Fields my $frame_charge = $main_window->Frame(-background=>'#FFFFFF')- +>pack(side=>'left'); my $charge_10 = $frame_charge->Text(-width=>12, -height=>1)->pack( +side=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_9 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_8 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_7 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_6 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_5 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_4 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_3 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_2 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); my $charge_1 = $frame_charge->Text(-width=>12, -height=>1)->pack(s +ide=>'bottom'); $frame_charge->Label(-text=>'Charge', -background=>'#FFFFFF')->pack(side=>'bottom'); sub PROCESS { #--- GET all Text Field Entries --- my $admission_1_value = $admission_1->get('1.0', 'end'); my $admission_2_value = $admission_2->get('1.0', 'end'); my $admission_3_value = $admission_3->get('1.0', 'end'); my $admission_4_value = $admission_4->get('1.0', 'end'); my $admission_5_value = $admission_5->get('1.0', 'end'); my $admission_6_value = $admission_6->get('1.0', 'end'); my $admission_7_value = $admission_7->get('1.0', 'end'); my $admission_8_value = $admission_8->get('1.0', 'end'); my $admission_9_value = $admission_9->get('1.0', 'end'); my $admission_10_value = $admission_10->get('1.0', 'end'); my $charge_1_value = $charge_1->get('1.0', 'end'); my $charge_2_value = $charge_2->get('1.0', 'end'); my $charge_3_value = $charge_3->get('1.0', 'end'); my $charge_4_value = $charge_4->get('1.0', 'end'); my $charge_5_value = $charge_5->get('1.0', 'end'); my $charge_6_value = $charge_6->get('1.0', 'end'); my $charge_7_value = $charge_7->get('1.0', 'end'); my $charge_8_value = $charge_8->get('1.0', 'end'); my $charge_9_value = $charge_9->get('1.0', 'end'); my $charge_10_value = $charge_10->get('1.0', 'end'); #-- Define Column Arrays --- my @patients = ("$admission_1_value", "$admission_2_value", "$admi +ssion_3_value", "$admission_4_value", "$admission_5_value", "$admission_6_ +value", "$admission_7_value", "$admission_8_value", "$admission_9_ +value", "$admission_10"); my @charge = ("$charge_1_value", "$charge_2_value", "$charge_3_val +ue", "$charge_4_value", "$charge_5_value", "$charge_6_value", + "$charge_7_value", "$charge_8_value", "$charge_9_value", + "$charge_10_value"); my @INVOICE = ("@patients", "\n", "@charge"); #--- PRINT ALL ENTRIES print @INVOICE; }; #--- Create GUI -- MainLoop;

As you can see when you run that code that if you fill up all the fields with text or anything, they all work except Admission #10. It instead prints "Tk::Text=HASH(0x2477ce0)". I've been trying for hours on what could be goin wrong but haven't had any success =\

If anybody could please lead me in the in right direction on this, it would be greatly appreciated! Thanks. =)

janitored by ybiC: Balanced <readmore> tags around long codeblock


In reply to Unexpected Error While Retreiving Text in Perl\Tk by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.