librelist archives

« back to archive

Green Shoes: use of & and <

Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-03 @ 08:30
Hi,

I am reading about the differences between the red and the green shoes
and could anyone clarify the difference about the use of '&' and '<'.

Are these the only two special characters that are handled differently
and does this mean that nowhere in the code should I use '&' regardless
whether it appears in a string or as an operator?

regards,
seba

Re: [shoes] Green Shoes: use of & and <

From:
ashbb
Date:
2012-09-03 @ 12:57
Hi Sebastjan,

Oh, good question!
You can use '&' as an operator. You have to use '&' and '<' in a
string.

Regards,
ashbb

Re: [shoes] Green Shoes: use of & and <

From:
Jenna Fox
Date:
2012-09-03 @ 13:02
I am horrified trying to understand why this would be the case.  

Horrified.


—
Jenna


On Monday, 3 September 2012 at 10:57 PM, ashbb wrote:

> Hi Sebastjan,
>  
> Oh, good question!
> You can use '&' as an operator. You have to use '&' and '<' in a string.
>  
> Regards,
> ashbb

Re: [shoes] Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-03 @ 13:43
Hi Jenna,

I am afraid I don't understand what you mean.

seba


Dne 03.09.2012 (pon) ob 23:02 +1000 je Jenna Fox napisal(a):
> I am horrified trying to understand why this would be the case. 
> 
> 
> Horrified.
> 
> 
> 
> 
> —
> Jenna
> 
> 
> 
> On Monday, 3 September 2012 at 10:57 PM, ashbb wrote:
> 
> > Hi Sebastjan,
> > 
> > Oh, good question!
> > You can use '&' as an operator. You have to use '&' and '<'
> > in a string.
> > 
> > Regards,
> > ashbb
> > 
> 
> 

Re: [shoes] Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-03 @ 21:25
Hi ashbb,

the reason I am asking is that I've written a program that helps me
check duplicate hotkey assignments. The trick is that I import the
strings to be checked from a plain .txt file and the hotkeys are denoted
with an ampersand: &Open

Would I have to replace all the ampersands in the .txt file prior to
importing them into the program?

regards,
sebastjan



Dne 03.09.2012 (pon) ob 21:57 +0900 je ashbb napisal(a):
> Hi Sebastjan,
> 
> Oh, good question!
> You can use '&' as an operator. You have to use '&' and '<' in
> a string.
> 
> Regards,
> ashbb

Re: [shoes] Green Shoes: use of & and <

From:
ashbb
Date:
2012-09-04 @ 12:19
Hi Sebastjan,

Now I understand your situation. ;-)

> Would I have to replace all the ampersands in the .txt file prior to
> importing them into the program?
There is no need to do so.
It's necessary to display the string with TextBlock (i.e. para, title,
etc.) only.
Try out the following.

require 'green_shoes'
Shoes.app do
  str = "ampersand &"
  puts str
  button str
  edit_line text: str
  para str.gsub('&', '&')
end

Regards,
ashbb

Re: [shoes] Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-09 @ 18:40
Dne 04.09.2012 (tor) ob 21:19 +0900 je ashbb napisal(a):
> Hi Sebastjan,
> 
> Now I understand your situation. ;-)
> 
> > Would I have to replace all the ampersands in the .txt file prior to
> > importing them into the program?
> There is no need to do so.
> It's necessary to display the string with TextBlock (i.e. para, title,
> etc.) only. 
> Try out the following.
> 
> require 'green_shoes'
> Shoes.app do
>   str = "ampersand &"
>   puts str
>   button str
>   edit_line text: str
>   para str.gsub('&', '&')
> end
> 
> Regards,
> ashbb


Hi ashbb,

I made a simple gui in green_shoes for this program of mine and as I ran
it it seems to handle the ampersands just fine without your recommended
modification.

I import the strings as they are: &Open file

and process them. So the array strings includes imported strings as they
are.

regards,
seba 

Re: [shoes] Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-09 @ 19:22
Dne 04.09.2012 (tor) ob 21:19 +0900 je ashbb napisal(a):
> Hi Sebastjan,
> 
> Now I understand your situation. ;-)
> 
> > Would I have to replace all the ampersands in the .txt file prior to
> > importing them into the program?
> There is no need to do so.
> It's necessary to display the string with TextBlock (i.e. para, title,
> etc.) only. 
> Try out the following.
> 
> require 'green_shoes'
> Shoes.app do
>   str = "ampersand &"
>   puts str
>   button str
>   edit_line text: str
>   para str.gsub('&', '&')
> end
> 
> Regards,
> ashbb

Actually, green_shoes don't handle the ampersand in strings:)

I mean it works as long it's not explicitly stated. So I can have my
program read a string with an ampersand from a file, process it and
write it back in the file.

Then I wanted the output to be also printed out inside a stack and there
it didn't work. I have to do the replacement.

regards,
seba

Re: [shoes] Green Shoes: use of & and <

From:
Sebastjan Hribar
Date:
2012-09-10 @ 12:24
I am having trouble displaying the output in a stack. I tried according
to the example below but no success.

I have an array of ampersand and letters combinations like so:

unused = ["&d", "&r", "&u"]

I would like to display this array in a separate stack. I tried
replacing but it doesn't seem to work. And I don't know how to display
it with TextBlock correctly.

I use 
----------------------------------------------------
para @unused.each {|x| x.gsub!("&", "&")}
----------------------------------------------------

but instead of displaying the output, the app crashes with:


-----------------------------------------------------------------------------------------------------

/home/sebastjan/.rvm/gems/ruby-1.9.3-p194/gems/green_shoes-1.1.365/lib/shoes/ruby.rb:107:in
`exit': wrong number of arguments (1 for 0) (ArgumentError)

from 
/home/sebastjan/.rvm/gems/ruby-1.9.3-p194/gems/glib2-1.1.5/lib/glib2.rb:33:in
`exit_application'

from 
/home/sebastjan/.rvm/gems/ruby-1.9.3-p194/gems/green_shoes-1.1.365/lib/shoes/main.rb:109:in
`main'

from 
/home/sebastjan/.rvm/gems/ruby-1.9.3-p194/gems/green_shoes-1.1.365/lib/shoes/main.rb:109:in
`app'
	from gs_dup_app.rb:3:in `<main>'

-----------------------------------------------------------------------------------------------------

regards
seba


Dne 09.09.2012 (ned) ob 21:22 +0200 je Sebastjan Hribar napisal(a):
> Dne 04.09.2012 (tor) ob 21:19 +0900 je ashbb napisal(a):
> > Hi Sebastjan,
> > 
> > Now I understand your situation. ;-)
> > 
> > > Would I have to replace all the ampersands in the .txt file prior to
> > > importing them into the program?
> > There is no need to do so.
> > It's necessary to display the string with TextBlock (i.e. para, title,
> > etc.) only. 
> > Try out the following.
> > 
> > require 'green_shoes'
> > Shoes.app do
> >   str = "ampersand &"
> >   puts str
> >   button str
> >   edit_line text: str
> >   para str.gsub('&', '&')
> > end
> > 
> > Regards,
> > ashbb
> 
> Actually, green_shoes don't handle the ampersand in strings:)
> 
> I mean it works as long it's not explicitly stated. So I can have my
> program read a string with an ampersand from a file, process it and
> write it back in the file.
> 
> Then I wanted the output to be also printed out inside a stack and there
> it didn't work. I have to do the replacement.
> 
> regards,
> seba

Re: [shoes] Green Shoes: use of & and <

From:
ashbb
Date:
2012-09-11 @ 13:43
Hi Sebastjan,

Umm,... strange.
Could you show me your code?

I tried the following two. They worked well.
Could you try them out on your platform?

# snippet1
require 'green_shoes'
Shoes.app do
  unused = ["&d", "&r", "&u"]
  para unused.each{|x| x.gsub!("&", "&")}
end

# snippet2
require 'green_shoes'
Shoes.app do
  unused = ["&d", "&r", "&u"]
  unused.each do |x|
    stack do
      border green
      para x.gsub("&", "&")
    end
  end
end

Regards,
ashbb