PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Strange errors on Mac OS X.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Strange errors on Mac OS X.

Réponse
 
LinkBack Outils de la discussion
Vieux 03/12/2007, 04h07   #1
Gabriel N.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Strange errors on Mac OS X.

I was wondering if anyone could out a newbie in need. So I've just
started learning Ruby, my first programming language. I've been going
through this online book, and when running one of the programs from the
book, I've been encountering a strange error. The program can be found
here (it's the one that writes numbers out in English), or you can check
out the attachment, where I've included it:

http://pine.fm/LearnToProgram/?Chapter=08

I was running it unchanged from the website. I've tested it out on three
computers, all Macs, but I always get this error:

numwrite.rb:1: syntax error
# Now here- write*100 # Subtract off those hundreds.ite
out?ut.n',
^

The line of code it shows is gibberish, it seems to be made up of
several lines of code mixed together. I've tested it on a Powerpc eMac
running OS X 10.2 and Ruby 1.8.2, an Intel Macbook running 10.4 and Ruby
1.8.6, and a Powerpc iBook running 10.4 and (I think) Ruby 1.8.4. All of
these give me something similar to this error.
Does anybody know what is going on, and can , please?

Attachments:
http://www.ruby-forum.com/attachment/1085/numwrite.rb

--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 03/12/2007, 04h31   #2
Giles Bowkett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

Hi Gabriel - I just copied and pasted your attachment and it ran
without any issues on my laptop, a MacBook Intel Core Duo running OS X
10.4.11 (bought nearly exactly one year ago). I ran it through two
versions of Ruby, 1.8.4 and 1.8.6, both were fine.

It looks like something weird is going on, wish I could be more
specific. There's nothing wrong with the code that I can see.

--
Giles Bowkett

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com

On 12/2/07, Gabriel N. <gabrielbn@hotmail.com> wrote:
> I was wondering if anyone could out a newbie in need. So I've just
> started learning Ruby, my first programming language. I've been going
> through this online book, and when running one of the programs from the
> book, I've been encountering a strange error. The program can be found
> here (it's the one that writes numbers out in English), or you can check
> out the attachment, where I've included it:
>
> http://pine.fm/LearnToProgram/?Chapter=08
>
> I was running it unchanged from the website. I've tested it out on three
> computers, all Macs, but I always get this error:
>
> numwrite.rb:1: syntax error
> # Now here- write*100 # Subtract off those hundreds.ite
> out?ut.n',
> ^
>
> The line of code it shows is gibberish, it seems to be made up of
> several lines of code mixed together. I've tested it on a Powerpc eMac
> running OS X 10.2 and Ruby 1.8.2, an Intel Macbook running 10.4 and Ruby
> 1.8.6, and a Powerpc iBook running 10.4 and (I think) Ruby 1.8.4. All of
> these give me something similar to this error.
> Does anybody know what is going on, and can , please?
>
> Attachments:
> http://www.ruby-forum.com/attachment/1085/numwrite.rb
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


  Réponse avec citation
Vieux 03/12/2007, 12h40   #3
has
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

On 3 Dec, 04:07, "Gabriel N." <gabrie...@hotmail.com> wrote:

> The line of code it shows is gibberish, it seems to be made up of
> several lines of code mixed together.


Might be that your code is using carriage returns instead of linefeeds
as end-of-line delimiters. Not sure about Ruby, but I know Python only
recognises LFs as linebreaks. Prior to OS X, Mac OS used CRs as
standard, and some Mac apps still do.

HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
  Réponse avec citation
Vieux 03/12/2007, 14h56   #4
Phrogz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

On Dec 2, 9:07 pm, "Gabriel N." <gabrie...@hotmail.com> wrote:
> I was wondering if anyone could out a newbie in need. So I've just
> started learning Ruby, my first programming language. I've been going
> through this online book, and when running one of the programs from the
> book, I've been encountering a strange error. The program can be found
> here (it's the one that writes numbers out in English), or you can check
> out the attachment, where I've included it:
>
> http://pine.fm/LearnToProgram/?Chapter=08
>
> I was running it unchanged from the website. I've tested it out on three
> computers, all Macs, but I always get this error:


If you copy and paste text from a website, particularly when is has
been syntax colored and otherwise formatted, you can occasionally get
junk characters. (Most commonly, non-breaking spaces look like spaces
in your text editor but have a different ascii value, and confuse the
interpreter.)

Did you copy and paste the colored text from the website?
  Réponse avec citation
Vieux 03/12/2007, 23h01   #5
Gabriel N.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

Gavin Kistner wrote:
> Did you copy and paste the colored text from the website?


Yes, yes I did. After seeing this, I tried copy-pasting a non-break
space and using find/replace to replace them with normal spaces, but it
seems as though the text editor doesn't differentiate between non-break
spaces and normal ones, as it was telling me that every space was a
non-break space, even after I replaced them. I am still getting the
error. This sounds plausible, though, are there any other characters
that, coming from websites, break Ruby?

> Might be that your code is using carriage returns instead of linefeeds
> as end-of-line delimiters. Not sure about Ruby, but I know Python only
> recognises LFs as linebreaks. Prior to OS X, Mac OS used CRs as
> standard, and some Mac apps still do.


I've been using Textedit, if that's any , in plain text mode. Though
honestly, I have no clue what you're talking about.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 03/12/2007, 23h19   #6
Florian Aßmann
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

Just replace

def englishNumber number

with

def englishNumber(number)

=2E.. in this case Ruby shouldn't care about LineFeeds and/or CarriageRet=
urns.

Cheers
Florian

Ruby with camelCase... yuck!


  Réponse avec citation
Vieux 04/12/2007, 00h36   #7
John Joyce
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.


On Dec 3, 2007, at 6:44 AM, has wrote:

> On 3 Dec, 04:07, "Gabriel N." <gabrie...@hotmail.com> wrote:
>
>> The line of code it shows is gibberish, it seems to be made up of
>> several lines of code mixed together.

>
> Might be that your code is using carriage returns instead of linefeeds
> as end-of-line delimiters. Not sure about Ruby, but I know Python only
> recognises LFs as linebreaks. Prior to OS X, Mac OS used CRs as
> standard, and some Mac apps still do.

No mac apps use CR as line endings now. That went away with OS9's
demise.
OS X and native apps all use Unix line endings as standard and as
defaults.
That means what you call LF, or line feed, or \n


  Réponse avec citation
Vieux 04/12/2007, 00h56   #8
Giles Bowkett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange errors on Mac OS X.

> def englishNumber number
>
> with
>
> def englishNumber(number)
>
> ... in this case Ruby shouldn't care about LineFeeds and/or CarriageReturns.


I thought that might be the issue, too, but it ran without my needing
to edit that.

--
Giles Bowkett

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14826 seconds with 16 queries