CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

get_long

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jelodavid



Joined: 03 Apr 2005
Posts: 22
Location: Laguna Philippines

View user's profile Send private message Yahoo Messenger

get_long
PostPosted: Wed May 11, 2005 3:24 am     Reply with quote

hello everyone! Please help me what's wrong with my code... I always get "Undefined identifier get_long" error.

Code:
#include <16f876.h>

//#device ICD=TRUE
#fuses  HS,NOLVP,NOWDT,PUT,NOPROTECT
#use delay(clock=8000000)

#define GREEN_LED   PIN_A5
#define YELLOW_LED  PIN_B4
#define RED_LED     PIN_B5
#define PUSH_BUTTON PIN_A4

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

wait_for_one_press()
{
    while(input(PUSH_BUTTON));
    delay_ms(100);
    while(!input(PUSH_BUTTON));
}

typedef enum {GREEN,YELLOW,RED} colors;

show_binary_on_leds(int n)
{
    output_high(GREEN_LED);
    output_high(YELLOW_LED);
    output_high(RED_LED);

    if (bit_test(n,0))
        output_low(GREEN_LED);
    if (bit_test(n,1))
        output_low(YELLOW_LED);
    if (bit_test(n,2))
        output_low(RED_LED);
}


//#include <protoalone.h>
//#include <utility.c>
#include <input.c>

main()
{
    long a,b,result;
    char opr;

    setup_timer_0(RTCC_INTERNAL);

    while(TRUE)
    {
        printf("\r\nEnter the first number: ");
        a=get_long();

        do
        {
            printf("\r\nEnter the operator (+-*/): ");
            opr=getc();
        }while(!isamoung(opr,"+-/"));

        printf("\r\nEnter the second number: ");
        b=get_long();

        switch(opr)
        {
            case '+' : result=a+b; break;
            case '-' : result=a-b; break;
            case '*' : result=a*b; break;
            case '/' : result=a/b; break;
        }

        printf("\r\nThe result is %lu ",result);
    }
}
Ttelmah
Guest







PostPosted: Wed May 11, 2005 3:59 am     Reply with quote

Look in the manual. Search for 'get_long'. Is it listed. No. This is not an 'intrinsic' function, so the compiler does not know how to handle this code. The function is an 'extra', defined in 'input.c', so this file must be included in the code, before it can be used.

Best Wishes
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed May 11, 2005 9:05 am     Reply with quote

Before using get_long you must include <stdlib.H> in the Header

#include <16f876.h>
#include <stdlib.H>
//#device ICD=TRUE



Best wishes,

Humberto
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed May 11, 2005 9:55 am     Reply with quote

Two additional commnets:

1) In your code you defined:
Code:

main()
{
    long a,b,result;



then you copied the obtained get_long in the variable a:
Code:

         a=get_long();

Be aware that get_long() returns a signed long value.


2) In the printf:
Code:

printf("\r\nThe result is %lu ",result);

you are using long unsigned again, take in mind that result is a signed long value.

To read what you expect replace lu by ld in the printf statement:
Code:

printf("\r\nThe result is %ld ",result);


best wishes,

Humberto
jelodavid



Joined: 03 Apr 2005
Posts: 22
Location: Laguna Philippines

View user's profile Send private message Yahoo Messenger

PostPosted: Thu May 12, 2005 5:34 am     Reply with quote

Very Happy Smile Laughing thanks for the great help...!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group