Quick C preprocessor format question

Really 2 questions. I want to use the same macro name to generate a list of fields, a list of method declarations and the code for the needed methods. What I am not sure about is (1) how to enclose a parameter to the macro so it will appear in a string in one definition, and (2) as part of a concatenated method name.
My example#define name(par1,par2) -(void)par1:(int)par2;
name(Name,myPoint)Gives me:-(void)Name:myPoint;No problem. Simple.
For (1) will:#define name(par1,par2) NSString par1 = @"par2";
name(myName,myPoint)give meNSString myName = @"myPoint";
or
NSString Name = @"par2";
From my understanding I think that will do what I want and give me @"myPoint".
For (2) What I want is:#define name(par1,par2) -(void)makeSome'par1:(int)par2;
name(Name,myPoint)and get
-(void)makeSomeName:(int)myPoint;
I haven't been defining macros in C for a long long time, and I know this is possible, just not what syntax to use to make it work. I used the quote character to show concatenation, which some other macro processors I have used use. Someone with experience here, point me to a reference on C preprocessor macros formatting would be good.
A correct example on how to define the 2nd macro would also help
There's really not much in my K&R C Programming language, circa 1978 2nd printing...

There's a section on the preprocessor in the book Beginning Mac OS X Programming by Wrox, but it's all based around C, not Objective-C like the code in your examples, so I don't know if that would be helpful to you or not.
I'm not a very experienced programmer, so I was hesitant to even reply, and I'll warn you now that I don't think this post will be of any help to you, but since you haven't gotten any other replies yet, I figured I'd try. Hopefully someone else around here will come along and actually help you.
Anyways, let's say you had two functions defined in your program -- their declarations are:
void PrintAddresses( );
void PrintPhoneNumbers( );
you could ideally use a macro as a way of calling the desired function. In C, the basic syntax for writing a macro like the one you wrote often uses the ternary operator. I don't know enough about Objective-C to know how that would fit in, but in C it would be simple enough:
#define Macro(param1, param2) (condition ? PrintAddresses : PrintPhoneNumbers)
the condition could be anything (param1 > param2 for example). Then, later, if you need to choose a method name based on the criteria passed to the macro, you would pass the appropriate arguments to the macro to get the ternary operator to return the desired value. The function call would be something like this:
Macro(arg1, arg2)( );
The compiler never sees the preprocessor directives. The preprocessor simply runs over your code before the compiler gets to it, replacing any macros with the values specified for them. So, if the arguments passed to the macro resulted in the condition in the ternary operator in the #define directive to be true, then the words "Macro(arg1, arg2)" would be replaced with "PrintAddresses" and your function call would now look like "PrintAddresses( );" and thus the function PrintAddresses( ) would be called. If the arguments passed to the macro resulted in the condition being false, then the words "Macro(arg1, arg2)" would be replaced with "PrintPhoneNumbers" and your function call would now look like "PrintPhoneNumbers( );" and thus the function PrintPhoneNumbers( ) would be called.
Note that if you take out the word "Print" from the macro values and try to define the macro like this:
#define Macro(param1, param2) (condition ? Addresses : PhoneNumbers)
and call the function like this:
PrintMacro(arg1,arg2)();
it will not work like this (or at least I could not get it to work like this) -- I don't know why.
Anyways, you probably already knew everything I just wrote, in which case maybe it can help someone else down the line searching through this thread. Or maybe I should just stick to asking questions on this forum. Anyways, hope the post wasn't a complete waste of time. Best of luck in solving your problem.
Message was edited by: Tron55555

Similar Messages

  • Landscape formatting question

    Can anyone help me with a formatting question? I have a number of PDFs that are landscape format. Every time I open them they default to portrait, even when I change orientation in page set-up and re-save...

    You are only changing the view, not the pdf. Use the Rotate command in the Document menu, not the view menu.

  • Locale Formatting question

    Locale Formatting question
    In the preceding code the number 50 represent currency.
    The output of NumberFormat is 50 with the local symbol
    The output of DecimalFormat is 50.00 without the local symbol
    The question is how to show 50.00 with the local symbol ???
    import java.text.*;
    import java.math.BigDecimal;
    public class LocalFormating {
    public static void main(String[] args) {
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    DecimalFormat decfs = new DecimalFormat("#,##0.00");
    BigDecimal anumb = new BigDecimal(50);
    String temp = nf.format(anumb);
    System.out.println("local anumb = " +temp);
    String temp2 = decfs.format(anumb);
    System.out.println("Decimal format anumb = " +temp2);

    Locale Formatting question
    In the preceding code the number 50 represent currency.
    The output of NumberFormat is 50 with the local symbol
    The output of DecimalFormat is 50.00 without the local symbol
    The question is how to show 50.00 with the local symbol ???
    import java.text.*;
    import java.math.BigDecimal;
    public class LocalFormating {
    public static void main(String[] args) {
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    DecimalFormat decfs = new DecimalFormat("#,##0.00");
    BigDecimal anumb = new BigDecimal(50);
    String temp = nf.format(anumb);
    System.out.println("local anumb = " +temp);
    String temp2 = decfs.format(anumb);
    System.out.println("Decimal format anumb = " +temp2);

  • Can you quick fill a format?

    Hello.
    I'm trying to do some presentation cards for school. I have the format ready, all I need to do is to fill the gaps with the kids names. The problem is, there's over 500 kids.
    I was wondering if there was a tool or something to quick fill the formats instead of filling them one by one. I have the names on a list, so I can copy & paste them over, but it still is very tedious.
    Or maybe just a way to have the text boxs preset in the format so I don't have to create one for every name.
    Here's the format.
    Thanks a lot in advance.

    Using Photoshop data driven graphics you can generates cards for each kid. https://www.youtube.com/watch?v=i9Ms34nYRFI
    Very easy to do that with Photoshop and my Photoshop script pasteimageroll.  The script will tile image into a new document. In your case you would prepare one image the aspect ratio you  want the tiles to be as a template for data driven graphics. Then create the kid cards.  Then run my script set the DPI you want to print at and the paper width the you want to use and set the tile size and number of image copies you want in your case 1  then let the script run by clicking ok. The script will present you with an open dialog select all your kids card image. For example if you want 3" x 2" cards without boarder like you show set the script dialog like this: 12" wide roll paper 4 cards per row 500 cards would require around 20' of roll paper.  You can create smaller document by selecting fewer images to print on sheet paper. On 13"x19" paper 36" images would fit. On 8.5" x 11"  rotate tiles to 2"x3" that will handle 12 cards per sheet like your sample image.
    The script is included in my Photo Collage Toolkit here is how the script works with examples http://www.mouseprints.net/old/dpr/PasteImageRoll.html
    The following example was for 4"  wide by 6" high tiles on 12" paper the rotate option has the script rotate images to the tile orientation for best fit.

  • Cascading lookup format questions

    Hi everyone,
       I have a couple of questions regarding formatting the cascading look up fields.  I have a list that filters classes and mnemonics by educator which works fine however on the entry form, when the "Educators" drop down menu is changed,
    a secondary description box appears. The question is, how do I get rid of that secondary description box?
    The second formatting question is that when I have filled out the form, on the edit entry form, there is a hyperlink to the list that the cascading lookup is using as a reference. How do I get rid of that link? See image 002 below

    It's not easy to understand the question, please attach the image here.
    if you mean to achieve a cascade lookup in SharePoint new/edit form, after selecting one column, the cascaded column below will show with filtered value, otherwise, the column is hidden, you may consider to use JavaScript/JQuery to show/hide the second column,
    following is an article about how to use cascaded lookup in SharePoint:
    http://www.sharepointboris.net/js/spcd/
    Qiao Wei <br/> My blog:http://blog.goobol.com

  • A quick page formatting question

    Hi all,
    Just a quick question. I am doing a contact page and I want to lay it out like this:
    Address:      Company
                       Address Line 1
                       Address Line 2
                       City
    Home phone: 123456
    Cell:              123456
    How do I do this in dreamweaver? It won't recognize tabs or more than one space. It's driving me insane and I can't see any way around it

    Since you can't use tables, why not use Definition Lists?  This works in all browsers including IE6/7. 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Sample Definition Lists</title>
    <style type="text/css">
    dt {
    float:left;
    font: bold 12px/1 "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    width: 6em;
    text-align: right;
    margin: 0;
    padding: 0;
    dd {
    font:normal 14px/1.2 Tahoma,Geneva, Arial, Helvetica, sans-serif;
    margin:0;
    padding: 0 0 0 6.10em;
    dl {
    clear:left;
    margin: 0.65em 0;
    padding: 0;
    </style>
    </head>
    <body>
    <!--Begin Definition Lists -->
    <dl>
    <dt>Address:</dt>
    <dd>Company Name</dd>
    <dd>Address 1</dd>
    <dd>Address 2</dd>
    <dd>City, Province,  Postal Code</dd>
    </dl>
    <dl>
    <dt>Phone:</dt>
    <dd>0-123-456-7890</dd>
    </dl>
    <dl>
    <dt>Fax:</dt>
    <dd>0-123-456-7890</dd>
    </dl>
    <dl>
    <dt>Cell:</dt>
    <dd>0-123-456-7890</dd>
    </dl>
    <dl>
    <dt>E-mail:</dt>
    <dd>[email protected]</dd>
    </dl>
    <dl>
    <dt>Website:</dt>
    <dd>http://example.com</dd>
    </dl>
    <!--end definition lists -->
    </body>
    </html>
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Basic Mac / DOS format question

    I need to transfer some large video files from a friend's MAC system to another friends Windows system.  They're 4.2 GB each.
    I do have a NTFS driver on my own MAC system, so I can bring the files home and copy them from the MAC drive to an NTFS drive.
    However, I would just as soon eliminate that extra step.  (I'd have to bring it back here, and it would add an extra day to the process.)
    My question: if I were to bring a standard DOS (not NTFS) portable drive, would it be able to accommodate files of that size (4.2 GB).  Is that the limit?
    Thanks!  I appreciate it. I know this question is a comparatively easy one for most of the members of this focum!
    w

    WillFriedwald2 wrote:
    thanks!  that was very quick.  3.9999 is the limit - the "old" DOS system is technically called "ex-FAT" or something like that, as I recall. 
    Anyhow. most importantly, MAC can read an ex-FAT drive without an additional drivers or modifications, so I have to get the guy to generate slightly smaller files.
    thanks again,
    w
    No, the 'old' Dos format is called FAT32 and is the one with the sub 4GB limit. eXFat can accommodate files larger than 4GB and should work for your purpose but is a less reliable system, use it for transfer, not for long term storage.
    Here's a link to the Wiki page for eXFat

  • Flash Output Format Question

    I did a search on this in the forum and looked thru google
    but there doesn't seem to be an answer anywhere, even though I'm
    sure there is one. I've made a flash animation movie with Adobe
    Flash and I'd like to upload it to youtube. The problem is, youtube
    doesn't accept SWF format. I tried to use my Total Video Converter
    to convert my SWF file to mpg, but the converter can't read it. So,
    I published a Quicktime .mov of my movie in Flash 8. But Youtube
    couldn't read my published .mov. I then tried to put that .mov into
    my converter but it still couldn't read it. So, I then tried to use
    the Adobe Flash Encoder; it doesn't seem to read SWF. So, I used it
    to convert my .mov into an FLV, hoping that I could then convert
    the FLV to mpg. All that got me was a totally blank video.
    I'm sure there's an answer to this, as Youtube is full of
    people's flash animations, but I just can't figure it out.
    Please, how do you format a flash video created in Adobe
    Flash CS3 for upload to sites such as Youtube?
    I'd really appreciate any help. Thanks.

    Rex Ross wrote:
    So, my question is this:
    If one were to run Compressor to create  a file which is suitable for upload to Vimeo and for use on an Apple TV 3, it appears as if any of these pre-sets would be suitable.
    Well, Vimeo will take just about anything you feel like uploading, so you're more or less correct on that score. They recompress the file, no matter what you give them. If you over-shoot their ideal format  – by giving them a lot more data then they need, the excess data will get tossed out when they re-compress. Beyond a certain data rate, it doesn't seem to make a difference although there are people who upload files @ 25 Mbs and even higher. Of course, the reverse is not true; if you give them a 1080p file @ 2 Mbps, you probably won't be pleased.
    There are some differences. The video sharing preset produces a Quick Time .mov. The two Apple device output files are MP4 with the iTunes extension of m4v. I'VE never tried to upload an MP4 with that extension, but it would probably work. If Vimeo (or YT)  balked, it would be easy enough to change the extension to mp4. Another difference is the audio streams; a 48 KHz sample rate for the mov and 44.kHz1 for the MP4.
    I'm pretty sure that a mov file will play on ATV. But I'm also pretty sure that it would not play on an iPad.
    That they are all variations on the h.264 codec is not surprising since it's highly efficient at delivering good quality in small file sizes.
    Russ

  • Adding loops and loops format question

    Hi, i've been facing difficulties adding loops into my GB. My problem is: "Loops do not appear in my loop browser nor the loop list from the silver loop bar above the browser".
    Yes, forgive me for asking this repeated question but after checking the help tutorial, my personal GB guide books, and even HangTime's FAQ, sadly, i still dont find any answers.
    Generally, the procedure is pretty simple from all the sources i've read. Simply drag the folder or loops into the browser and thats DONE right? I did exactly what it said but sigh...maybe there's something wrong with my Macbook?
    For your information, all the loops that i've been adding are loops from CDs coupled with FutureMusic and ComputerMusic magazines, so i believe the sources are pretty reliable i hope.
    As i was struggling to add the loops, this msg popped up for the first time; "Loops that are not in Apple format will not be added into GB"
    So, is the loop format the main cause of my problem?
    if yes, is there any way to convert the format? what is the procedure?
    ps: My current status is, some loops i added are in my browser while some dont although they exist in User/Library/Audio/AppleLoops/UserLoops.
    Thank you in advance.
    Peace

    So, is the loop format the main cause of my problem?
    likely.
    if yes, is there any way to convert the format? what is the procedure?
    apple's loop utility:
    http://www.bulletsandbones.com/GB/GBFAQ.html#looputility
    also note:
    http://www.bulletsandbones.com/GB/GBFAQ.html#missingloops

  • Converting from PDF directly to Java Objects/XML (and PDF format questions)

    Hi,
    I posted this originally in the Acrobat Windows forums but was told I might have more luck here, so here goes:
    I am desperately trying to find a tool (preferably open source but commercial is fine also) that will sit on top of a PDF and allow me to query it's text for content and formatting (I don't care about images). I have found some tools that get me part of the way there, but nothing that seems to provide an end-to-end solution but is quite lightweight. My main question is WHY are there so many tools that go from PDF to RTF, and many tools that go from RTF to XML, but NONE that I can find that go PDF to XML.
    To clarify, by formatting I simply mean whether a line/block of text is bold/italic, and its font size. I am not concerned with exact position on the page. The background is that I will be searching PDFs and assigning importance to whether text is a heading/bodytext etc. We already have a search tool in place so implementing a pure PDF search engine is not an option. I need a lightweight tool that simply allows me to either make calls directly to the PDF OR converts to XML which I can parse.
    Some tools I have tried:
    1) PDFBox (Java Library) - Allows the extraction of text content easily, but doesn't seem to have good support for formatting.
    2) JPedal (Java Library) - Allows extraction of text content easily, and supports formatting IF XML structured data is in the PDF (not the case for my data).
    3)  Nitro PDF (Tool) + RTF to XML (script) - This works quite nicely and shows that PDF to XML is possible, but why do I have to use 2 tools? Also, these are not libraries I can integrate into my app.
    4) iText (Java Library) - Seems great at creating PDFs but poor at extracting content.
    I don't really expect someone to give me a perfect solution (although that would be nice!).
    Instead, what I'd like to know is WHY tools support PDF to RTF/Word/whatever retaining formatting, and other tools support RTF to XML with the formatting information retained. What is it about PDF and RTF/Word that makes it feasible to convert that way, but not to XML. Also, as I found in 3) above, it is perfectly feasible to end up as XML from PDF, so why do no tools support this reliably!
    Many thanks for any advice from PDF gurus.

    XML doesn't mean anything - it's just a generic concept for structuring
    information.  You need a specific GRAMMAR of XML to mean anything.  So what
    grammar would you use?  Something standard?  Make up your own?
    However, there are a number of commercial and open source products that can
    convert PDF to various XML grammars - SVG, ABW, and various custom grammars.
    But the other thing you need to understand is that most PDF files do not
    have any structure associated with them (as you saw when using JPEDAL).  As
    such, any concepts of paragraphs/sections/tables/etc. Are WILD GUESSES by
    the software in question.

  • And a partition in a pear tree...format question

    Well, I've spent almost an hour of my life I won't get back. Trying to archive an iDVD project (33gb) from internal hard drive to new Lacie 160g external. Keep getting "Error in archiving project" message. Even though I was able to copy some large folders onto the drive, with no problem, iDVD doesn't like that the drive is apparently formatted to FAT. I assume. Whatever. Okay, I'll play: I'm ready to reformat the drive. Understand HOW....but that's not the question....
    "You can choose up to eight partitions." Okay, Eight. How about seven? Why not 1,000? How do I, as the APPLE tech support docs says, "choose the number of partitions I want" if I don't have a clue as to why I am choosing them. I figured two would be good enough. So, any help would be appreciated (I've copied the files back over to what's left of the hard drive so I can format now with impunity. I hope this solves the "you can't get there from here after spending more time and money" message. All I want to do is archive the files so I can get 155gb of the 160gb hard drive back. And understand "choose the number of partitions you want" and run the disk utility instruction.

    Hi TuckerdogAVL
    What you need to do is partition the drive in Mac OS extended for it to work with iDVD6.
    Go to applications>Utilities>Apple's DU
    The procedure might look something like this:
    Click Here
    Hope this is Helpful.
    P.S. I like the title to your Post! (Merry X-mas).

  • Chart Formatting Question: Line Bar Combo

    Hello -
    I have a quick question regarding the order of labels displayed in the legend on a line bar combo chart. I have figured out how to rearrange the order of bars in the chart (the order is determined by the order of fields in the criteria section), however, OBIEE seems to always put the "line" field before the "bar" fields in the legend.
    I was wondering if there is a way to set the chart to display the "line" field following the "bar" fields in the legend?
    Thanks for the help!
    Jason

    Hi Jason,
    Go for Pivot Chart rather than Chart... and
    Apply Order by s as you want inside pivot....
    Previously even i got the order by problem in chart.. but trying the pivot chart, i resolved my issue...
    So give a try..
    Hope you know about pivot chart. Select Chart Only option from drop-down available for chart position
    Thanks & Regards
    Kishore Guggilla

  • Photo format question

    Newbie question: when designing an ID document (let's say ID CS4, since that's what I'm using), is there any difference in placing a Photshop image (.ps) versus a .TIF file? I've done both. And is there any harm in using high-res .JPG's? I have a friend who works in Quark and he always changes every photo to .TIF before placing. Thanks.

    Resizing is a different issue altogether from format.
    It's safe to scale the image in ID regardless of the format. If you look in the info panel with the image selected you'll see two resolution numbers listed, actual and effective. Actual is just the resolution at the dimensions the image was saved and is essentially irrelevant. Effective resolution is what you have at the dimensions you are currently using, and that's the number that counts. If that number is in the range that is acceptable for the type of output you are using, there is no need to resize the image in Photoshop at all.
    If you MUST resize the image, then yes, convert to something besides jpeg if that's what it is to start. And keep in mind that up-sampling won't improve image quality in general, and downsampling more than 20% or so can cause you to lose fine details (but so will scaling down).
    Peter

  • Apple mail formatting Question

    I just bought a MBAir and in using Apple mail I cannot seem to format email replies to contain an extra two lines of blank space above the original email.  Is there a way to format email replies to do this automatically?

    Roland,
    What is the question? The reference to the system administrator, is more in reference to how the IMAP server is configured. Does this IMAP work, as expected?
    Ernie

  • Ps3 format question, and more..thanks

    hi guys, i transferred a hd movie from my sony camera to my ps3 it plays great, when i copyed the movie from my ps3 to a external hdd, to edit with imov09, it wont play. the file is there, any ideas>
    also i took a clip of it and converted it to mp4, and another to quick time, they played ok, however when i dragged across to edit in movie 09 ,it wont allow them in to be edited ?
    where am i going wrong? any help would be great.
    thank you.

    Here are ones that appleman posted -- they will work for imovie9 just use export quicktime movie
    I did some experimentation based on a post by Dan Hawkins in the "Pro" forums. I experimented with his settings using the Quicktime Export option in iMovie 08 and they worked. His post is below.
    ============================================================
    from Dan Hawkins:
    I am using a PS3 to preview HD video edited in FCE-3.5.1HD with the following QT-PRO export settings:
    1) export from FCE using Quicktime conversion
    2) select format MPEG-4
    3) select options:
    a) under file format select MP4 (not MP4 ISMA)
    b) under video tab select H.264
    data rate in the range of about 10000 to 18000 kbits/sec depending on what filesize/quality you are shooting for
    image size---select 1280X720HD or 1920X1080HD
    frame rate---select 29.97 or "current" if already on a editing timeline of that type
    key frame---select either automatic or every 24 frames
    video options---select "MAIN" profile and single pass encoding (when I use "MULTI-PASS" encoding I get a "FILE UNREADABLE" error message on my PS3)
    c) under audio tab select default AAC-LC
    d) under streaming tab select default "not enabled"
    I transfer the resulting high definition .MP4 file to the PS3 by one of the following methods:
    ethernet network connection
    iPod/thumb drive
    SD-card
    I have to hit the "alternate menu" under the PS3 video section and select "display all files" to see the video file and then save it to the local PS3 HDD (some dumb programming there!).
    I have heard there might be an upper limit of 4Gb on the file size (if so, another dumb move), but have not come across that limitation yet (I just got the PS3 about a week ago and am working through some of the same issues you seem to be struggling with).
    I think that some of the confusion regarding the PS3 relative to playing back HD from regular DVD-R is that the PS3 will hardware decode a properly encoded .MP4 HD video file from whatever media it is presented on and as such does not require a HD "authoring" container with menus and such. These so called "HD authoring tools" are currently in a pretty confused state at the moment and are the source of much incompatibility with many HD playback devices, but the PS3 bypasses all of that and plays the file directly through hardware decoding.
    ========================================================
    along with this thread
    http://discussions.apple.com/thread.jspa?messageID=7022027&#7022027
    Message was edited by: Sheryl Kingstone

Maybe you are looking for

  • Adobe3DAndVideoServer.exe not working when CS6 Bridge Launched 64 Bit on Win 7 64 Bit

    QuickTime 7.7.3 Windows 7 64 Bit All windows updates applied Video driver updated all adobe updates ran for bridge and PS CS6 Cleaned out preferences Launching Bridge now responds with "Adobe3DAndVideoServer.exe not working" with no help of what to d

  • IPhoto will not import certain JPG files

    I have just migrated to a 2012 Retina 15" MacBook Pro from a 13" MBP. I am using Mavericks 10.9.1 and iPhoto 9.5.1. The MBP is a 2.7gHz quad core with 16GB of memory and a 768GB SSD. I was trying to tidy up my hard disc and import some .jpg files fro

  • Dynamic Entity Member Lists using UD1 and UD2

    Hello fellow HFM gurus: I have created dynamic member lists to get all members of the entity dimension that have a UD1 or UD2 member as specified in the script. THe member lists all appear in HFM, but when I try to select them, I get a run-time error

  • How to fit the data in Oracle SPOOL FIle

    Hi all, Word_rapped ,Formatted etc etc dif every thing ... Some columns data arent fitting in to the page.What I want to fit the ouput of query in to one page (A4). is there any SPOOL command to fit

  • WLS 10.3 - Self Registration with External LDAP Fails (somewhat)

    I have a WLS 10.3.5 instance with WebCenter Spaces. I've added an OpenLDAP provider to the security realm, set the OpenLDAP provider and the default authenticator to "sufficient", and reordered the providers in the console to list the OpenLDAP provid