• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Other option rather than .rsrc in Xcode...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Other option rather than .rsrc in Xcode...


  • Subject: Re: Other option rather than .rsrc in Xcode...
  • From: Dave Carrigan <email@hidden>
  • Date: Wed, 17 Dec 2008 15:20:09 -0800


On Dec 17, 2008, at 2:40 PM, Nima wrote:

You could of course just put it in a large constant string, or take advantage of C's automatic concatenation of consecutive string literals:

char * myScript = "function inDate() {\n"
                              s=prompt(\"input date:\");\n"

Etc.

The maintenance of the newlines and escaping of the quotes is a pain, but if this is a one-time thing you can do it with find and replace.

Chris

Thanks Chris,
I wish there was a better approach as you mentioned the maintenance is not an easy thing to do.

Put your javascript into a file write a script that creates a .h file with syntactically-correct C, and #include that .h file. Add a build rule that will run the script on your input files and create .h files.


The script is pretty simple. Off the top of my head, written in mail.app:

#! /usr/bin/perl -n

BEGIN {
  print "char const* myscript = ";
}

while (<>) {
  chomp;
  s/\\/\\\\/g;
  s/\"/\\\"/g;
  print '"', $_, '"', "\n";
}

END {
  print ";\n";
}


-- Dave Carrigan email@hidden Seattle, WA, USA

Attachment: PGP.sig
Description: This is a digitally signed message part

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Other option rather than .rsrc in Xcode...
      • From: Steve Checkoway <email@hidden>
References: 
 >Other option rather than .rsrc in Xcode... (From: Nima <email@hidden>)
 >Re: Other option rather than .rsrc in Xcode... (From: Chris Espinosa <email@hidden>)
 >Re: Other option rather than .rsrc in Xcode... (From: Nima <email@hidden>)

  • Prev by Date: Re: Other option rather than .rsrc in Xcode...
  • Next by Date: iPhone Question
  • Previous by thread: Re: Other option rather than .rsrc in Xcode...
  • Next by thread: Re: Other option rather than .rsrc in Xcode...
  • Index(es):
    • Date
    • Thread