Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Perl CGI and scrolling_list

I have created an array (@desc) which I am loading into a scrolling_list.  The array is built from a file.  THe file contains lines like:  name      desc
                      another      desc  
The problem is that when the list is diplayed, the space in
between the columns disappears.  It is displayed as:
                     name desc
                     another desc
If I print the array to a file, the columns are preserved. Is the scrolling_list automatically removing extra white space?  It leaves ONE space but not more than that?  

Can I preserve my columns?

For now I have dots as a spacer.  name.....desc but I'd rather use tabs.
0
wspoulin
Asked:
wspoulin
  • 5
  • 2
  • 2
1 Solution
 
wspoulinAuthor Commented:
Well, I have just reviewed my question and see that my extra
white space has been removed!!!  I guess I know the answer!

Still, I'd like to know if there is a way around it.

For clarification my file looks like:

      name<spaces or tab........> desc
      another name<spaces or tab> desc2

But my display looks like:

      name desc
      another name desc2
0
 
n3mtrCommented:
What is scrolling_list?  Did you write it yourself or is it part of some package?
Is this displayed on a browser?  Browsers get rid of extra spaces. You could convert to tables(better), or convert to non breaking spaces(&nbsp).

0
 
n3mtrCommented:
Another thing, if its not displayed on a web browser you could modify scrolling list to not get rid of the extra spaces.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
wspoulinAuthor Commented:
scrolling_list is part of CGI.pm. It is displayed in Netscape.

The code is as follows:

$query->scrolling_list(
  -name=>'projects',
  -values=>[@some_names],
  -default=>$selected,
  -size=>15,
  -onChange=>"refresh()");

@some_names has rows consisting of:   name (tabs) desc

When you say convert to &nbsp do you mean to store &nbsp in the array?  I have tried that and it dispalys: "name&nbsp desc"!



 
When you say, "convert to ... (&nbsp)" do you mean in the array?

0
 
julio011597Commented:
It is "&nbsp;", you missed last char.
It follows the rules for non-printable chars's symbolic names.

Another *nice* workaround is putting your list inside the pair <PRE>...</PRE>; let tabs stay into the list and try this.

Cheers, julio
0
 
wspoulinAuthor Commented:
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 
wspoulinAuthor Commented:
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 
julio011597Commented:
No, i meant the html looking something like:

<PRE>
<SELECT...>
<OPTION...>
...
</SELECT>
</PRE>

so, in your code, output the 'PRE' tags before and after the list object.

Going back to your question, surrounding the list with <PRE>...</PRE> would allow you to put any spaces or tabs you need and get them preserved when displayed.

Anyway, i cannot guess why the "&nbsp;" didn't work.
As a suggestion, you could try to get rid of the scrolling_list object, and set up the corresponding code yourself (just a matter of a few print()'s): sometimes, working with third parties libraries may cause just headaches!

-julio
0
 
wspoulinAuthor Commented:
Well, I give up!  PRE tags do not preserve it either.  I
think you are correct about the third party utils.  Maybe I
need an upgrade.  

But I will just type the code myself for now.

Thanks for the help!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now