IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Rock Ridge Farm (Larry) on March 17, 2006, 07:26:08 AM

Title: Pointer math question
Post by: Rock Ridge Farm (Larry) on March 17, 2006, 07:26:08 AM
In C this works:
    char buffer[80],*ptr;

    /* buffer contains "abc123" */
    *ptr = &buffer[0];
    *ptr++;

Aurora does not like '*ptr++".
How would I do this?
Title: Re: Pointer math question
Post by: Ionic Wind Support Team on March 17, 2006, 07:31:22 AM
Well it depends on what your trying to do.  If your reading the buffer and then incrementing the pointer then you need two statements.

chr = *ptr;
ptr++;

Title: Re: Pointer math question
Post by: Rock Ridge Farm (Larry) on March 17, 2006, 07:41:45 AM
I am trying to move to the next char position in the buffer.
I am doing *ptr++ should it be ptr++ with no *?
Title: Re: Pointer math question
Post by: Ionic Wind Support Team on March 17, 2006, 07:50:41 AM
Yes.  *ptr dereferences the pointer and returns a character.

ptr++;   increments the pointer
Title: Re: Pointer math question
Post by: Rock Ridge Farm (Larry) on March 17, 2006, 07:52:45 AM
This is the code I am trying to make work:

InternetReadFile(hhttp,buffer,254,br);
buffer = left$(buffer,br);
IF(br) {
ptr = buffer;
ptr++;
while(*ptr != '"' && *ptr != null)
                ptr++;
if(*ptr == ',')
ptr++;
cst = *ptr;
while(*ptr != ',' && *ptr != null)
ptr++;
ptr = null;
ptr++;
m_lstprc = USING("#######.##&",cst);
hstmt_update = NULL;
hstmt_update = m_db.PrepareSQL("UPDATE stock SET lstprc=? WHERE               id="+NumToStr(m_id));

       m_db.BindParameter(hstmt_update,1,m_lstprc,TYPE_double,8);
       m_db.Execute(hstmt_update);
       m_db.FreeSQL(hstmt_update);

      messagebox(0, buffer,"Quote");
}

I have tried many combinations of * and no * still not working.
Title: Re: Pointer math question
Post by: Ionic Wind Support Team on March 17, 2006, 08:00:06 AM
You've got a mix of C and Aurora there.

&& in C is AND in Aurora
== in C is = in Aurora

Fix those problems first.

Use a string type and get rid of the pointers if you wish. Remember in Aurora a string can be accessed like an array directly.

dstring buffer[80];
...
int ptr =1;
while((buffer[ptr] != '"') AND (buffer[ptr] != null))
    ptr++;
if(buffer[ptr] = ',')
    ptr++;

Or forge ahead with pointers and see how much you can learn.