Page 3 of 7 FirstFirst 123456 ... LastLast
Results 21 to 30 of 65
  1. #21

    Default Re: goto statement - any comment


    bai gamit kaayo na nako ang GOTO bai kay awa ha...

    Example:

    Private Sub Form_load()

    On error Goto Here
    Adod1.recordsource = "select * from Tinfo where EmpId = '" & Text1.text & "' "
    Adodc1.Refresh

    Here: Exit Sub
    End Sub

  2. #22

    Default Re: goto statement - any comment

    Hehehehe... sa VB mana... syempre gamit jud diba...
    How about in C/C++

  3. #23

    Default Re: goto statement - any comment

    kung ganahan ka makahibaw jud kun gunsa gamit ana ug kung ngano naay goto nga command..try ug download ug linux kernel source code(maski unsa nga version), then browse through the codes unya sabta..tan aw di ba daghan gamit ang goto

  4. #24

    Default Re: goto statement - any comment

    Quote Originally Posted by zengatsu
    kung ganahan ka makahibaw jud kun gunsa gamit ana ug kung ngano naay goto nga command..try ug download ug linux kernel source code(maski unsa nga version), then browse through the codes unya sabta..tan aw di ba daghan gamit ang goto
    just because it's in linux kernel it doesnt mean it's useful and not avaoidable. They're humans pud baya.

  5. #25

    Default Re: goto statement - any comment

    Quote Originally Posted by gloryhunter
    Quote Originally Posted by zengatsu
    kung ganahan ka makahibaw jud kun gunsa gamit ana ug kung ngano naay goto nga command..try ug download ug linux kernel source code(maski unsa nga version), then browse through the codes unya sabta..tan aw di ba daghan gamit ang goto
    just because it's in linux kernel it doesnt mean it's useful and not avaoidable. They're humans pud baya.
    well i think it is useful..i think the performance wouldnt be the same if they didnt use it..about sa usefulness sad diay niya bay, i dont think that functionality will be provided if it has no use at all..

  6. #26

    Default Re: goto statement - any comment

    from gen_init_cpio.c:

    static int cpio_mkfile(const char *name, const char *location,
    unsigned int mode, uid_t uid, gid_t gid)
    {
    char s[256];
    char *filebuf = NULL;
    struct stat buf;
    int file = -1;
    int retval;
    int rc = -1;

    mode |= S_IFREG;

    retval = stat (location, &buf);
    if (retval) {
    fprintf (stderr, "File %s could not be located\n", location);
    goto error;
    }

    file = open (location, O_RDONLY);
    if (file < 0) {
    fprintf (stderr, "File %s could not be opened for reading\n", location);
    goto error;
    }

    filebuf = malloc(buf.st_size);
    if (!filebuf) {
    fprintf (stderr, "out of memory\n");
    goto error;
    }

    retval = read (file, filebuf, buf.st_size);
    if (retval < 0) {
    fprintf (stderr, "Can not read %s file\n", location);
    goto error;
    }

    sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
    "%08X%08X%08X%08X%08X%08X%08X",
    "070701", /* magic */
    ino++, /* ino */
    mode, /* mode */
    (long) uid, /* uid */
    (long) gid, /* gid */
    1, /* nlink */
    (long) buf.st_mtime, /* mtime */
    (int) buf.st_size, /* filesize */
    3, /* major */
    1, /* minor */
    0, /* rmajor */
    0, /* rminor */
    (unsigned)strlen(name) + 1,/* namesize */
    0); /* chksum */
    push_hdr(s);
    push_string(name);
    push_pad();

    fwrite(filebuf, buf.st_size, 1, stdout);
    offset += buf.st_size;
    push_pad();
    rc = 0;

    error:
    if (filebuf) free(filebuf);
    if (file >= 0) close(file);
    return rc;
    }


    tan awa ninyo mga syo, i dont think ispagiti code na eh..depende ra na sa pag code bay uy..kung ma spaghetti imong code if mugamit ka ug goto, pasabot ana dili kamao or plain tapulan lang ka

  7. #27

    Default Re: goto statement - any comment

    Quote Originally Posted by zengatsu
    from gen_init_cpio.c:

    static int cpio_mkfile(const char *name, const char *location,
    unsigned int mode, uid_t uid, gid_t gid)
    {
    char s[256];
    char *filebuf = NULL;
    struct stat buf;
    int file = -1;
    int retval;
    int rc = -1;

    mode |= S_IFREG;

    retval = stat (location, &buf);
    if (retval) {
    fprintf (stderr, "File %s could not be located\n", location);
    goto error;
    }

    file = open (location, O_RDONLY);
    if (file < 0) {
    fprintf (stderr, "File %s could not be opened for reading\n", location);
    goto error;
    }

    filebuf = malloc(buf.st_size);
    if (!filebuf) {
    fprintf (stderr, "out of memory\n");
    goto error;
    }

    retval = read (file, filebuf, buf.st_size);
    if (retval < 0) {
    fprintf (stderr, "Can not read %s file\n", location);
    goto error;
    }

    sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
    "%08X%08X%08X%08X%08X%08X%08X",
    "070701", /* magic */
    ino++, /* ino */
    mode, /* mode */
    (long) uid, /* uid */
    (long) gid, /* gid */
    1, /* nlink */
    (long) buf.st_mtime, /* mtime */
    (int) buf.st_size, /* filesize */
    3, /* major */
    1, /* minor */
    0, /* rmajor */
    0, /* rminor */
    (unsigned)strlen(name) + 1,/* namesize */
    0); /* chksum */
    push_hdr(s);
    push_string(name);
    push_pad();

    fwrite(filebuf, buf.st_size, 1, stdout);
    offset += buf.st_size;
    push_pad();
    rc = 0;

    error:
    if (filebuf) free(filebuf);
    if (file >= 0) close(file);
    return rc;
    }


    tan awa ninyo mga syo, i dont think ispagiti code na eh..depende ra na sa pag code bay uy..kung ma spaghetti imong code if mugamit ka ug goto, pasabot ana dili kamao or plain tapulan lang ka
    Not a good code for me.. Just like you are coding in Visual Basic...

    Maybe the developers are not good in software designing....
    If that code will be reviewed together with the Senior Developers and Leaders, Im sure you get failed...

    Maybe in assembly language, that is acceptable.....
    That type of coding I think exists from 80's but currently since different coding standard and optimzation exist, that is not recommended.

  8. #28

    Default Re: goto statement - any comment

    @xyberblue: How would you recode that then? So that it would become a good code for you? oh and by the way, that for the 2.6.14 kernel..the latest stable build as of this post..so i dont think this is an 80s type of coding but if it is, i think 80s has a good style too

  9. #29

    Default Re: goto statement - any comment

    Quote Originally Posted by zengatsu
    @xyberblue: How would you recode that then? So that it would become a good code for you? oh and by the way, that for the 2.6.14 kernel..the latest stable build as of this post..so i dont think this is an 80s type of coding but if it is, i think 80s has a good style too
    Mostly error trapping just issue a return type and issue an error message to the main functions. I think that's not best code to show that goto should take part. There something part in the kernel that is so difficult to return to the exact part of the program. The code above can be revised and not a good example of the usefulness of goto. Though I have not read all the code yet in kernel but I believe there is something there that goto is justifiable...

  10. #30

    Default Re: goto statement - any comment

    actually the sample code is doing exactly what you said..you know error trapping and return type..thing is, to make the code elegant for better performance, the goto part is needed..you cud actually rewrite it in a short circuit kind of way like you log a message if you find an error then return directly to the main function, but then freeing of the buffer and the closing of the file has to be included inside each of your if statements..or you cud enclose all the steps in separate if-else statements then check for errors and return types from previous statements before executing any of the following statement then finally return to the calling function, which wud be more work of the processor..this code is actually an efficient one and an elegant one at that

    and its also an example of a code supporting the claim that using goto will not turn your code into ispagiti code..ill just post a sample of the codes youre looking for when i stumble upon such a code..im sure i will..im tinkering with the kernel right now..tuon2 lang..heheheh..till then, peace mga bro!!!

  11.    Advertisement

Page 3 of 7 FirstFirst 123456 ... LastLast

Similar Threads

 
  1. Any comments on Lami-Ah??
    By darkwing in forum Food & Dining
    Replies: 10
    Last Post: 02-21-2009, 06:37 AM
  2. Replies: 4
    Last Post: 10-05-2007, 10:12 PM
  3. any comment sa Palit gf8500gt sonic and gt8600gt sonic
    By baijo in forum Computer Hardware
    Replies: 28
    Last Post: 06-01-2007, 11:12 PM
  4. Comparing 3 Switches, Any Comments...
    By Chipmunk888 in forum Networking & Internet
    Replies: 21
    Last Post: 10-27-2006, 07:45 AM
  5. Brighton monitor? Any comment on this?
    By erik garcia in forum Computer Hardware
    Replies: 2
    Last Post: 12-03-2005, 10:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top