AllBASIC

BASIC Developer & Support Resources => Translators => C BASIC => Topic started by: Charles Pegge on November 11, 2013, 01:01:45 PM

Title: C Basic Class Library
Post by: Charles Pegge on November 11, 2013, 01:01:45 PM
This code is still very volatile but I will start posting here.

The strings are simpler - one global controls the character width.

The sequence of file is important: - sort of linear hierarchy:

It will now compile with both GCC 4.7.0 and VC10 (without using compiler switches)

Code: [Select]
  #include <stdarg.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <math.h>
  #include "BasicDefine.h"
  #include "GenericClass.c"
  #include "PoolClass.c"
  #include "StringClass.c"
  #include "LexiClass.c"

Objects are generally contained within a single memory block and have the same base header. An object may contain any number of items in a contiguous block. For instance, strings contain an array of characters; a particle object will contain an array of particles.

If the array needs to be stretch then the whole object is re-dimensioned into a new memory block, and the original is freed.

Code: [Select]
  types ClassStruct
  begin
  ref f;  // pointer to methods/function table
  int type;   // dynamic type code
  int offset; // size of this header (jump to data)
  int nbytes; // buffer size for body of data
  int count;  // number of elements
  int size;   // size of each element
  end
  Class,*Object;
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 01:11:22 PM
Thanks Charles !!!

Sorry for losing faith.  :-X
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 01:19:07 PM
Works on Ubuntu 64.

Code: [Select]
jrs@laptop:~/C_BASIC/cbc$ gcc Test.c -o test1
jrs@laptop:~/C_BASIC/cbc$ ./test1

LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
       \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 38547666
Word End:   38547668
Text End:   38547672
=
jrs@laptop:~/C_BASIC/cbc$
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 11, 2013, 01:29:36 PM
It okay, John. Thanks for testing. I can see that the control chars come out invisible - presumably its the forum display.

I'm doing quite a lot of conceptual work, to take out as much entropy as possible from the code which involves extended  periods of gazing through the (void*)  :)
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 01:37:04 PM
You can see them in the attached screenshot.

Title: Re: C Basic Class Library
Post by: kryton9 on November 11, 2013, 01:53:03 PM
Can't wait to test it out later when I have time.
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 02:52:00 PM
Charles,

I have reformatted your StringClass.c to be friendlier to CINT's parser. If it wouldn't be too much trouble, can your follow this format going forward?

John

Code: [Select]

  typedef char StringType,*CharArray;

  typedef struct StringClassTableStruct StringClassTable,*StringMethods;

  int CharWidth=1; // 1 or 2

 class StringClassStruct
  begin
//BASE MEMBERS
  StringMethods f; // pointer to methods table
  int type;        // dynamic type code
  int offset;      // size of this header
  int nbytes;      // buffer ze for body of data
  int count;       // number of elements
  int size;        // size of each element
  end
  StringClass,*StringObject;


  types StringArrayStruct
  begin
  StringMethods f;
  int offset;
  int nbytes;
  int count;
  int size;
  end
  StringArrayType,  *StringArrayObject;



  #define Left(S,I)   GetMid(S,1,(I))
  #define Right(S,I)  GetMid(S,-(I),-1)


  dim StringMethods pStringMethods=0;


  sub CopyWidth(char *t, int tw, char *s, int sw, int count)
  begin
    //itr 32bit char widths?
    int i;
    if(tw==2)
    begin
      if (sw==2)
      begin
        short *ss=(ref) s;
        short *ts=(ref) t;
        for (i=0; to i<count; step incr i)
        begin
          *ts= *ss;
          incr ts;
          incr ss;
        end
        return;
      end
      if (sw==1)
        begin
        short *ts=(ref) t;
        for (i=0; to i<count; step incr i)
        begin
          *ts= *s;
          incr ts;
          incr s;
        end
        return;
      end
    end
    // otherwise copy lower bytes only
    for (i=0; to i<count; step incr i)
    begin
      *t= *s;
      t+=tw;
      s+=sw;
    end
  end


  function CharArray strptr(StringObject s)
  begin
    return (ref) s + s->offset;
  end


  function StringObject *straptr(StringArrayObject s)
  begin
    return (ref) s + s->offset;
  end


  function StringObject StringTransfer(StringObject *r,StringObject s)
  begin
    return Transfer((ref *)r, (ref) s);
  end


  function char* CharTransfer(char **r, char *s)
  begin
    return Transfer((ref) *r, (ref) s);
  end



  function StringMethods StringClassInit();


  function StringObject NewString(int nc)
  begin
    if (pStringMethods==0) then StringClassInit();
    return NewObject(pStringMethods, nc, CharWidth, sizeof(StringClass));
  end


  function StringArrayObject NewStringArray(int nc)
  begin
    if (pStringMethods==0) then StringClassInit();
    return NewObject(pStringMethods, nc, sizeof(ref), sizeof(StringArrayType));
  end


  //methods


  method StringObject StringFree(StringObject *pthis)
  begin
    StringObject this= *pthis;
    if (this==0) FreeSpace(this);
    *pthis=0;
    return 0;
  end


  method StringObject StringFreeN(StringObject *pthis, int n)
  begin
    int i;
    for (i==0; to i<n; incr i)
    begin
      StringObject this=pthis[i];
      if (this==0) FreeSpace(this);
      pthis[i]=0;
    end
    return 0;
  end


  method StringArrayObject StringArrayFree(StringArrayObject *pthis)
  begin
    StringArrayObject this= *pthis;
    if (this==0) then return 0;
    StringObject *ps = straptr(this);
    StringObject s;
    int n=this->count;
    if (n==0) then return 0;
    int i;
    for (i=0; to i<n; step incr i)
    begin
      s=ps[i];
      if (s) then free(s);
    end
    free(this);
    *pthis=0;
    return 0;
  end


  method StringObject StringCopy(StringObject *pthis, StringObject s)
  begin
    StringObject this= *pthis;
    int le=0, lt=0, wi=1, wt=1, oc=sizeof(StringClass);
    if (s)
    begin
      le=s->count;
      wi=s->size;
    end
    if (this)
    begin
      lt=this->count;
      wt=this->size;
      oc=this->offset;
    end;
    if ((this==0)or(lt *wt < le *wi)) then this = NewObject(pStringMethods, le, wt, oc);
    if (s) then CopyWidth(strptr(this), wt, strptr(s), wi,le);
    return StringTransfer(pthis,this);
  end


  method char *StringGetChars(StringObject *pthis, char **r)
  begin
    StringObject this= *pthis;
    int tc=0;
    if (this) then tc=this->count;
    char *s = NewSpace(CharWidth * tc +2);
    if (this) then CopyWidth(s, CharWidth, strptr(this), this->size, this->count+1);
    return CharTransfer(r,s);
  end


  method StringObject StringSetChars(StringObject *pthis, char *s)
  begin
    StringObject this= *pthis;
    int le;
    if (CharWidth==2)
    begin
      le=WordLen(s);
    end
    else
    begin
      le=ByteLen(s);
    end     
    int wt=CharWidth;
    if (this) then wt=this->size;
    if ((this==0)or(this->count < le)) then this = NewString(le);
    char *k=strptr(this);
    CopyWidth(k, wt, s, CharWidth, le); // autoconvert
    this->count=le;
    NullTerminate(k+le*wt);
    return StringTransfer(pthis,this);
  end


 method StringObject StringGetMid(StringObject *pthis, StringObject s, int i, int le)
  begin
    int lt=0;
    int wi=CharWidth;
    if (s) then lt=s->count;
    if ((s)and(wi<0)) then wi=s->size;  // default to s size
    if (le<0) then le=lt;         // default max
    if (i<0) then i+=lt+1;        // offset from right
    decr i;                       // indexbase 0
    if (le+i>lt) then le=lt-i;    // clip length
    if (i<0)  then i=0;           //clamp lower offset
    if (le<0) then le=0;          //clamp length >=0
    StringObject this= *pthis;
    if (wi<1) then wi=1;          // in case of null s
    if ((this==0)or(this->nbytes < le*wi)) then this = NewString(le);
    char *k=strptr(this);
    if (s) then CopyWidth(k, wi, strptr(s) + i * s->size, s->size, le);
    NullTerminate(k+le*wi);
    this->count=le;
    this->size=wi;
    return StringTransfer(pthis, this);
  end


  method StringObject StringSetMid(StringObject *pthis, int i, StringObject s)
  begin
    StringObject this= *pthis;
    if (this==0) then return 0;
    int lt=this member count;
    int le=s member count;
    if (i<0) then i+=1+lt;
    decr i;
    char *k = strptr(this)+ i * this->size;
    if (le+i>=lt) then le = lt-i;
    CopyWidth(k, this->size, strptr(s), s->size, le);
    return this;
  end


/* non-ellipsis Join: passing array instead

  method StringObject StringJoinArray(StringObject *pthis, int n, StringObject *jl)
  begin
    StringObject this = *pthis;
    int ne=0;
    int i;
    char *k;
    int wid=1;
    StringObject s;
    int tot=0;
    for (i=0; to i<n; step incr i)
    begin
      s=jl[i];
      if (s)
      begin
        tot+=s->count;
        if (s->size == 2) then wid=2;
        if(s==this) then ne=1; // force new join-buffer
      end
    end
    if ((ne==1)or(this==0)or( this->nbytes < tot*wid)) then this=NewString(tot);
    char *m = strptr(this);
    for (i=0; to i<n; step incr i)
    begin
      s=jl[i];
      k=strptr(s);
      CopyWidth(m, wid, k, s->size, s->count);
      m+=(s->count * wid);
    end
    NullTerminate(m);
    this->count = tot;
    this->size = wid;
    return StringTransfer(pthis,this);
  end
*/

  method StringObject StringJoin(StringObject *pthis, int n, ...)
  begin
    va_list marker;
    StringObject this = *pthis;
    int ne=0;
    int i;
    char *k;
    int wid=1;
    StringObject s;
    int tot=0;
    va_start(marker, n); // Initialize variable arguments
    for (i=0; to i<n; step incr i)
    begin
      s=va_arg(marker, StringObject); // get next StringObject
      if (s)
      begin
        tot+=s->count;
        if (s->size == 2) then wid=2;
        if(s==this) then ne=1; // force new join-buffer
      end
    end
    va_end(marker); // Reset variable arguments
    if ((ne==1)or(this==0)or( this->nbytes < tot*wid)) then this=NewString(tot);
    char *m = strptr(this);
    va_start(marker, n); // Initialize variable arguments
    for (i=0; to i<n; step incr i)
    begin
      s=va_arg(marker, StringObject); // get next StringObject
      k=strptr(s);
      CopyWidth(m, wid, k, s->size, s->count);
      m+=(s->count * wid);
    end
    va_end(marker); // Reset variable arguments
    NullTerminate(m);
    this->count = tot;
    this->size = wid;
    return StringTransfer(pthis,this);
  end


  method StringObject StringMerge(StringObject *pthis,StringArrayObject *plist, StringObject kw)
  begin
    StringArrayObject list= *plist;
    if (list==0) then list=NewStringArray(0);
    int wid=kw->size; // default char width
    StringObject this= *pthis;
    StringObject *jl=(ref) list + list->offset;
    StringObject s;
    int en=list->nbytes;
    int tot=0;
    int ne=0;
    int i;
    for (i=0; to i<en; step incr i)
    begin
      s=jl[i];
      if (s)
      begin
        tot += s->count;
        if (s->size == 2) then wid=2;
        if(s==this) then ne=1; // force new join-buffer
      end
      tot += kw->count;
    end
    if ((ne==1)or(this==0)or( this->nbytes < tot*wid)) then this=NewString(tot);
    char *m = strptr(this);   // accumulator buffer base
    char *km = strptr(kw); // marker string chars
    char *ks;              // array element chars
    int kl = kw->count * wid;
    for (i=0; to i<en; step incr i)
    begin
      s=jl[i];
      if (s)
      begin
        ks=strptr(s);
        CopyWidth(m, wid, ks, s->size, s->count);
        m+=(s->count * wid);
      end
      CopyWidth(m, wid, km, kw->size, kw->count);
      m+=kl;
    end
    //m-kl;   // excluding end marker
    NullTerminate(m-kl);
    this->count = tot - kw->count; // excluding end marker
    this->size = wid;
    StringArrayFree(&list);
    *plist=0;
    return StringTransfer(pthis,this);
  end

  method StringArrayObject StringSplit(StringObject *pthis, StringArrayObject *plist, StringObject kw)
  begin
    StringObject this = *pthis;
    if (this==0) then this=NewString(0);
    StringArrayObject list= *plist;
    if (list) StringArrayFree(&list);
    int b=1;
    int en=0; // count markers
    while(b)
    begin
      en++;
      b=StringInstr(pthis,b,kw);
      if (b)
      begin
        b+=kw->count;
      end
    end
    list->count=en;        // returning number of string segements
    b=1;                   // start of string segment
    int e;                 // boundary of string segment
    int le;                // length of string segment
    int d;                 // stride for next string segment
    char *m=strptr(this);   // string base
    int wid = this->size;  // character width
    list= NewStringArray(en);
    StringObject *li=(ref) list + list->offset;
    int i;
    for (i=0; to i<en; step incr i)
    begin
      e=StringInstr(&this, b, kw);      //locate boundary marker
      if (e==0) then e=1 + this->count; //locate boundary of string
      le=e-b+1;
      StringObject c=NewString(le);
      CopyWidth(strptr(c), wid, m, wid, le);
      d=le + kw->count; // string + marker
      b+=d;             // stride
      m+=(d * wid);     // next offset
      li[i]=c;          // assign string to array
    end
    *plist=list;
    return list;
  end



  method StringObject StringRepeat(StringObject *pthis, StringObject s ,int n)
  begin
    int i;
    char *k=strptr(s);
    int tot=s->count*n;
    int wid=s->size;
    StringObject c = *pthis;
    if ((c==0)or( c->nbytes < tot*wid)) then c=NewString(tot);
    char *m=strptr(c);
    for (i=1; to i<=n; step incr i)
    begin
      CopyWidth(m, wid, k, s->size, s->count);
      m+=(s->count * wid);
    end
    NullTerminate(m);
    c->count = tot;
    c->size = wid;
    return StringTransfer(pthis,c);
  end


  method StringObject StringLcase(StringObject *r, StringObject this)
  begin
    int i;
    int w=this->size;
    int n=this->count;
    StringObject s= *r;
    if ((s==0)or(s != this)) then s = StringCopy(&s,this);
    char *c = strptr(s);
    char a;
    for (i=0; to to i<n; incr i)
    begin
      a= *c;
      if ((a>65)and(a<91)) then *c=a+32;
      c+=w;
    end
    return StringTransfer(r,s);
  end


  method StringObject StringUcase(StringObject *r, StringObject this)
  begin
    int i;
    int w=this->size;
    int n=this->count;
    StringObject s= *r;
    if ((s==0)or(s != this)) then  s = StringCopy(&s,this);
    char *c = strptr(s);
    char a;
    for (i=0; to to i<n; incr i)
    begin
      a= *c;
      if ((a>96)and(a<123)) then *c=a-32;
      c+=w;
    end
    if (*r != this) then return StringTransfer(r,s);
    return this;
  end


  method StringObject StringLtrim(StringObject *r, StringObject this)
  begin
    int i;
    StringObject u= *r;
    int w=this->size;
    int n=this->count;
    char *c = strptr(this);
    if (w<2)
    begin
      i=0;
      while (i++ < n)
      begin
        if (*c>32) then break;
        c+=w;
      end
      return StringTransfer(r,StringGetMid(&u,this,i,-1));
    end
    else
    begin
      i=0;
      while (i++ <n)
      begin
        if ((c[0]>32)or(c[1])) then break;
        c+=w;
      end
      return StringTransfer(r,StringGetMid(&u,this,(i>>1)+1,-1));
    end
  end


  method StringObject StringRtrim(StringObject *r, StringObject this)
  begin
    int i;
    StringObject u= *r;
    int w=this->size;
    int n=this->count;
    char *c = w * n - w + strptr(this);
    if (w<2)
    begin
      i=n;
      while(i-- >0)
      begin
        if (*c>32) then break;
        decr c;
      end
      return StringTransfer(r,StringGetMid(&u,this, 1, i+1));
    end
    else
    begin
      i=n;
      while (i-- >0)
      begin
        if ((c[0]>32)or(c[1])) then break;
        c+=w;
      end
      return StringTransfer(r,StringGetMid(&u,this, 1, (i>>1)+1));
    end
  end


  method StringObject StringTrim(StringObject *r, StringObject this)
  begin
    int i;
    StringObject u= *r;
    int w=this->size;
    int n=this->count;
    char *c = w * n - w + strptr(this);
    if (w<2)
    begin
      i=0;
      while (i++ < n)
      begin
        if (*c>32) then break;
        c+=w;
      end
      int b=i;
      i=n;
      while(i-- >0)
      begin
        if (*c>32) then break;
        decr c;
      end
      return StringTransfer(r,StringGetMid(&u,this, b, i-b+1));
    end
    else
    begin
      i=0;
      while (i++ <n)
      begin
        if ((c[0]>32)or(c[1])) then break;
        c+=w;
      end
      int b=i;
      i=n;
      while (i-- >0)
      begin
        if ((c[0]>32)or(c[1])) then break;
        c+=w;
      end
      return StringTransfer(r,StringGetMid(&u,this, b, ((i-b)>>1)+1));
    end
  end


  method StringObject StringInsert(StringObject *pthis, StringObject s, int i)
  begin
    StringObject this= *pthis;
    int c=this->count;
    int w=this->size;
    StringObject tl=NewString(c);
    StringObject tr=NewString(c);
    StringJoin(pthis,3,StringGetMid(&tl,this,1,i-1), s, StringGetMid(&tr,this,i,-1) );
    StringFree(&tl);
    StringFree(&tr);
    return *pthis;
  end


  method StringObject StringDelete(StringObject *pthis, int i, int le)
  begin
    StringObject this= *pthis;
    int c=this->count;
    int w=this->size;
    StringObject tl=NewString(c);
    StringObject tr=NewString(c);
    StringJoin(pthis,2,StringGetMid(&tl,this,1,i-1), StringGetMid(&tr,this,i+le,-1) );
    StringFree(&tl);
    StringFree(&tr);
    return *pthis;
  end


  method StringObject StringChr(StringObject *r, int a)
  begin
    int le=CharWidth;
    StringObject s= *r;
    if ((s==0)or(s->nbytes < le*CharWidth)) then s = NewString(le);
    s->count=le;
    s->size=CharWidth;
    short *k=(short*)strptr(s);
    *k=a;
    return StringTransfer(r,s);
  end


  method StringObject StringStr(StringObject *r, double d)
  begin
    int wi=1;
    int le=32;
    StringObject s= *r;
    if ((s==0)or(s->nbytes < le*wi)) then s = NewString(le);
    char *k=strptr(s);
    sprintf(k,"%f",d);
    s->count=ByteLen(k);
    s->size=wi;
    return StringTransfer(r,s);
  end


  method int StringShow(StringObject *pthis)
  begin
    CharArray w=strptr(*pthis);
    printf("%s\n", w); // itr wide chars
  end


  method int StringAsc(StringObject *pthis, int i)   // also supports wide chars
  begin
    StringObject this= *pthis;
    if (i<0) then i+=this->count+1;            // offset from right
    if ((i>this->count)or(i<1)) then return 0; // out of range
    decr i;                                    // indexbase 0
    int wi=this->size;
    if (wi==1) then return *(strptr(this)+i);
    if (wi==2)
    begin
      short *a = (short*)strptr(this)+i*2;
      return *a;
    end
  end


  method int StringCmp(StringObject *pthis, StringObject k)
  //COMPARING MIXED WIDTHS
  begin
    StringObject this= *pthis;
    if ((this==0)and(k==0)) then return  0; // null match
    if (this==0)            then return -1; // no this
    if (k==0)               then return  1; // no k
    if ((this->count==0)and(k->count==0)) then return 0;  // both nulls
    if (this->count==0)  then return  1;                  // this is greater
    if (k->count==0)     then return -1;                  // this is less
    int tw=this->size;
    int kw=k->size;
    char *tc = strptr(this);
    char *kc=strptr(k);
    char *te=tc+this->count*tw;
    char *ke=kc+k->count*kw;
    if ((tw==2)and(kw==2)) // comparing 16bit characters
    begin
      short *tew=(ref) te;
      short *tcw=(ref) tc;
      short *kew=(ref) ke;
      short *kcw=(ref) kc;
      while (1)
      begin
        if (*tcw < *kcw) then return  -1; // this is less
        if (*tcw > *kcw) then return   1; // this is greater
        tcw++;
        kcw++;
        if ((tcw==tew)and(kcw==kew)) then return  0; // match
        if (kcw==kew)                then return  1; // end of k
        if (tcw==tew)                then return -1; // end of this
      end
      return 0;
    end
    //otherwise 8bit or mixed 8bit/16bit characters (comparing lower byte)
    while (1)
    begin
      if (*tc < *kc) then return  -1; // this is less
      if (*tc > *kc) then return   1; // this is greater
      tc+=tw;
      kc+=kw;
      if ((tc==te)and(kc==ke)) then return  0; // match
      if (kc==ke)              then return  1; // end of k
      if (tc==te)              then return -1; // end of this
    end
    return 0;
  end


  method int StringInstr(StringObject *pthis, int i, StringObject k)
  //MATCHING MIXED WIDTHS
  begin
    StringObject this= *pthis;
    if (this==0) then return 0; // no string to search
    if (k==0)    then return 0; // no keystring to use
    char *tb = strptr(this);
    char *tc=tb;
    char *kc=strptr(k);
    char *te=tc+this->count*this->size;
    char *ke=kc+k->count*k->size;
    if (i > this->count) then return 0;          // offset past end
    if (this->count==0)  then return 0;          // null search string
    if (i<0)             then i+=this->count+1;  // offset from right
    if (k->count==0)     then return 0;          // empty keyword
    decr i;                                      //indexbase 0
    tc+=i*this->size;                            // offset
    char *td;
    char *kd;
    int tw=this->size;
    int kw=k->size;
    if ((tw==2)and(kw==2)) // comparing 16bit characters
    begin
      short *tbw=(ref) tb;
      short *tew=(ref) te;
      short *tcw=(ref) tc;
      short *kew=(ref) ke;
      short *kcw=(ref) kc;
      short *kdw;
      short *tdw;
      while (tcw<tew)
      begin
        if (*tcw == *kcw)
        begin
          tdw=tcw;
          kdw=kcw;     
          while (*tdw == *kdw)
          begin
            tdw++;
            kdw++;
            if (kdw==kew) then return ((tcw-tbw)>>1)+1;  // match complete
            if (tdw==tew) then return 0;                 // end of main string
            if (*tdw == *tcw) then tcw=tdw-tw;             // possible next match
          end
        end
        tcw++;
      end
      return 0;
    end
    //otherwise 8bit or mixed 8bit/16bit characters (comparing lower byte)
    while (tc<te)
    begin
      if (*tc == *kc)
      begin
        td=tc;
        kd=kc;     
        while (*td == *kd)
        begin
          td+=tw;
          kd+=kw;
          if (kd==ke) then return ((tc-tb)>>(tw-1))+1; // match complete
          if (td==te) then return 0;                   // end of main string
          if (*td == *tc) then tc=td-tw;                 // possible next match
        end
      end
      tc+=tw;
    end
    return 0;
  end


  method double StringVal(StringObject *pthis)
  begin
  double d;
  sscanf(strptr(*pthis),"%lf ",&d);
  return d;
  end


  method StringObject StringReplace(StringObject *pthis, StringObject f , StringObject r)
  begin
    StringObject this= *pthis;
    if ((this==0)or(f==0)or(r==0)) then return this;
    if ((this->count==0)or(f->count==0)) then return this;
    int n=0;
    int i=1;
    while (i)
    begin
      i=StringInstr(&this, i, f);
      if (i)
      begin
        n++;
        i+=f->count;
      end
    end
    n *= (r->count - f->count);
    int tot = n + this->count;
    StringObject c = NewString(tot);
    char *m = strptr(c);
    int b=1,j=1;
    while (j)
    begin
      j=StringInstr(&this,b,f);
      if (j)
      begin
        if (j>b) then CopyWidth(m, c->size,strptr(this)+b-1,this->size,j-b);
        m += c->size * (j-b);
        CopyWidth(m,c->size,strptr(r),r->size,r->count);
        m += c->size * r->count;
        b=j + f->count; // skip by keyword length
      end
    end
    // remainder
    j = this->count + 1;
    if (j>b)
    begin
      CopyWidth(m,c->size,strptr(this)+b-1,this->size,j-b);
      m += c->size * (j-b);
    end
    NullTerminate(m);
    return StringTransfer(pthis,c);
  end


  types StringClassTableStruct
  begin
    method StringObject      (byref Free)      (StringObject *pthis);
    method StringObject      (byref FreeN)     (StringObject *pthis, int n);
    method StringArrayObject (byref ArrayFree) (StringArrayObject *pthis);
    method StringObject      (byref Copy)       (StringObject *pthis, StringObject s);
    method char*             (byref GetChars)  (StringObject *pthis, char **r);
    method StringObject      (byref SetChars)  (StringObject *pthis, char *c);
    method StringObject      (byref GetMid)    (StringObject *pthis, StringObject s, int i, int le);
    method StringObject      (byref SetMid)    (StringObject *pthis, int i, StringObject s);
//  method StringObject      (byref JoinArray) (StringObject *pthis, int n, StringObject *jl);
    method StringObject      (byref Join)      (StringObject *pthis, int n, ...);
    method StringObject      (byref Merge)     (StringObject *pthis, StringArrayObject *plist, StringObject kw);
    method StringArrayObject (byref Split)     (StringObject *pthis, StringArrayObject *plist, StringObject kw);
    method StringObject      (byref Repeat)    (StringObject *pthis, StringObject s ,int n);
    method StringObject      (byref Replace)   (StringObject *pthis, StringObject f , StringObject r);
    method StringObject      (byref Ucase)     (StringObject *r, StringObject this);
    method StringObject      (byref Lcase)     (StringObject *r, StringObject this);
    method StringObject      (byref Ltrim)     (StringObject *r, StringObject this);
    method StringObject      (byref Rtrim)     (StringObject *r, StringObject this);
    method StringObject      (byref Trim)      (StringObject *r, StringObject this);
    method StringObject      (byref Insert)    (StringObject *pthis, StringObject s, int i);
    method StringObject      (byref Delete)    (StringObject *pthis, int i, int le);
    method StringObject      (byref Chr)       (StringObject *r, int a);
    method StringObject      (byref Str)       (StringObject *r, double d);
    method int               (byref Show)      (StringObject *pthis);
    method int               (byref Asc)       (StringObject *pthis, int i);   // also supports wide chars
    method int               (byref Cmp)       (StringObject *pthis, StringObject k);
    method int               (byref Instr)     (StringObject *pthis, int i,  StringObject k);
    method double            (byref Val)       (StringObject *pthis);
  end
  StringClassTable,*StringMethods;

  function StringMethods StringClassInit()
  begin
    dim as static StringClassTable t;
    StringMethods f references t;
    f->Free       references StringFree;
    f->FreeN      references StringFreeN;
    f->ArrayFree  references StringArrayFree;
    f->Copy       references StringCopy;
    f->GetChars   references StringGetChars;
    f->SetChars   references StringSetChars;
    f->GetMid     references StringGetMid;
    f->SetMid     references StringSetMid;
//  f->JoinArray  references StringJoinArray;
    f->Join       references StringJoin;
    f->Merge      references StringMerge;
    f->Split      references StringSplit;
    f->Repeat     references StringRepeat;
    f->Replace    references StringReplace;
    f->Ucase      references StringUcase;
    f->Lcase      references StringLcase;
    f->Ltrim      references StringLtrim;
    f->Rtrim      references StringRtrim;
    f->Trim       references StringTrim;
    f->Insert     references StringInsert;
    f->Delete     references StringDelete;
    f->Chr        references StringChr;
    f->Str        references StringStr;
    f->Show       references StringShow;
    f->Asc        references StringAsc;
    f->Cmp        references StringCmp;
    f->Instr      references StringInstr;
    f->Val        references StringVal;
    pStringMethods=f;
    return f;
  end
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 03:15:49 PM
Charles,

I'm working on getting the modified version of your code working on C9 and Red Hat is complaining on the run but not the compile.

allbasic@c_basic:~/668428/usr/john/cbc $ ./t_cbc
./t_cbc: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
allbasic@c_basic:~/668428/usr/john/cbc $

The same code runs fine on Ubuntu 64 bit.

John
Title: Re: C Basic Class Library
Post by: AIR on November 11, 2013, 06:04:02 PM
On OSX 10.9:

Code: [Select]
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:7:
./GenericClass.c:159:3: warning: control may reach end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:7:
./GenericClass.c:171:3: warning: control may reach end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:7:
./GenericClass.c:183:3: warning: control may reach end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:7:
./GenericClass.c:200:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:9:
./StringClass.c:137:11: warning: equality comparison result unused [-Wunused-comparison]
    for (i==0; to i<n; incr i)
         ~^~~
./StringClass.c:137:11: note: use '=' to turn this equality comparison into an assignment
    for (i==0; to i<n; incr i)
          ^~
          =
./StringClass.c:398:9: warning: implicit declaration of function 'StringInstr' is invalid in C99 [-Wimplicit-function-declaration]
      b=StringInstr(pthis,b,kw);
        ^
./StringClass.c:655:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:9:
./StringClass.c:671:3: warning: control may reach end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:10:
./LexiClass.c:50:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word Start: %i\n",w->bp);
                        ~~    ^~~~~
                        %s
./LexiClass.c:51:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word End:   %i\n",w->ep);
                        ~~    ^~~~~
                        %s
./LexiClass.c:52:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Text End:   %i\n",w->et);
                        ~~    ^~~~~
                        %s
./LexiClass.c:53:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:10:
./LexiClass.c:60:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:10:
./LexiClass.c:142:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
In file included from Test.c:3:
In file included from ./BasicClassLibrary.h:10:
./LexiClass.c:159:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
Test.c:5:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  function TestStrings()
           ^~~~~~~~~~~
Test.c:75:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
17 warnings generated.

Result of execution:
Code: [Select]
[riveraa@Kitty ~/Downloads/CBasicClassLibrary] $ ./test
Segmentation fault: 11
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 06:09:42 PM
I don't know if this is related to my __vdso_time issue on C9 but when trying to run the phpinfo.php script I get the following in the Apache error_log.

Code: [Select]
[Mon Nov 11 21:03:27 2013] [error] [client 127.10.32.129] PHP Warning:  phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead in /var/lib/stickshift/525667ede0b8cd7b5d000021/app-root/data/642383/sbcgi/test.php on line 2, referer: https://c9.io/scriptbasic/c9basic
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 06:14:25 PM
Quote
#define end   }

Maybe OSX doesn't like the leading spaces. Try this.

Code: [Select]
#define end }
Title: Re: C Basic Class Library
Post by: AIR on November 11, 2013, 06:20:56 PM
That's not causing the warning, spaces are legal.
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 06:53:04 PM
This is the error I'm getting trying to compile Charles's (unmodified) current installment on CentOS release 6.4 (Final) 64 bit. (Red Hat clone)

Code: [Select]
[root@ip-10-200-134-45 cbasic]# gcc Test.c -o test1
In file included from BasicClassLibrary.h:9,
                 from Test.c:3:
StringClass.c:878: error: redefinition of typedef ‘StringClassTable’
StringClass.c:4: note: previous declaration of ‘StringClassTable’ was here
StringClass.c:878: error: redefinition of typedef ‘StringMethods’
StringClass.c:4: note: previous declaration of ‘StringMethods’ was here
[root@ip-10-200-134-45 cbasic]#

I tried to compile on a 32 bit version of CentOS 6.4 and got the same results.

Code: [Select]
[root@johns2 cbasic]# gcc Test.c -o test1
In file included from BasicClassLibrary.h:9,
                 from Test.c:3:
StringClass.c:878: error: redefinition of typedef ‘StringClassTable’
StringClass.c:4: note: previous declaration of ‘StringClassTable’ was here
StringClass.c:878: error: redefinition of typedef ‘StringMethods’
StringClass.c:4: note: previous declaration of ‘StringMethods’ was here
[root@johns2 cbasic]#
Title: Re: C Basic Class Library
Post by: AIR on November 11, 2013, 07:33:24 PM
I think Charles has standardized on C11.  When I turn it off on my Mac, I see this:

Code: [Select]
In file included from ./BasicClassLibrary.h:9:
./StringClass.c:878:3: warning: redefinition of typedef 'StringClassTable' is a C11 feature [-Wtypedef-redefinition]
  StringClassTable,*StringMethods;
  ^
./StringClass.c:4:41: note: previous definition is here
  typedef struct StringClassTableStruct StringClassTable,*StringMethods;
                                        ^
./StringClass.c:878:21: warning: redefinition of typedef 'StringMethods' is a C11 feature [-Wtypedef-redefinition]
  StringClassTable,*StringMethods;
                    ^
./StringClass.c:4:59: note: previous definition is here
  typedef struct StringClassTableStruct StringClassTable,*StringMethods;

So if your compiler supports it,try it like this: gcc Test.c -std=c11 -o test1
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 07:40:25 PM
CentOS 32 bit
[root@johns2 cbasic]# gcc Test.c -std=c11 -o test1
cc1: error: unrecognized command line option "-std=c11"
[root@johns2 cbasic]#

CentOS 64 bit - gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
[root@ip-10-200-134-45 cbasic]# gcc Test.c -std=c11 -o test1
cc1: error: unrecognized command line option "-std=c11"
[root@ip-10-200-134-45 cbasic]#

C9 Red Hat 64 bit - gcc version 4.7.2 20121015 (Red Hat 4.7.2-5) (GCC)
allbasic@c_basic:~/668428/usr/john/cbc $ gcc Test.c -std=c11 -o test1
In file included from BasicClassLibrary.h:9:0,
                 from Test.c:3:
StringClass.c: In function ‘StringSplit’:
StringClass.c:398:7: warning: implicit declaration of function ‘StringInstr’ [-Wimplicit-function-declaration]
Test.c: At top level:
Test.c:5:12: warning: return type defaults to ‘int’ [enabled by default]
allbasic@c_basic:~/668428/usr/john/cbc $ ./test1
./test1: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
allbasic@c_basic:~/668428/usr/john/cbc $ gcc Test.c -o test1
allbasic@c_basic:~/668428/usr/john/cbc $ ./test1
./test1: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
allbasic@c_basic:~/668428/usr/john/cbc $

Ubuntu 64 bit - gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)
jrs@laptop:~/C_BASIC/charles$ gcc Test.c -std=c11 -o test1
In file included from BasicClassLibrary.h:9:0,
                 from Test.c:3:
StringClass.c: In function ‘StringSplit’:
StringClass.c:398:7: warning: implicit declaration of function ‘StringInstr’ [-Wimplicit-function-declaration]
       b=StringInstr(pthis,b,kw);
       ^
Test.c: At top level:
Test.c:5:12: warning: return type defaults to ‘int’ [enabled by default]
   function TestStrings()
            ^
jrs@laptop:~/C_BASIC/charles$ ./test1

LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
       \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 9801938
Word End:   9801940
Text End:   9801944
=
jrs@laptop:~/C_BASIC/charles$
Title: Re: C Basic Class Library
Post by: AIR on November 11, 2013, 07:57:22 PM
c11 didn't really become available until gcc 4.7.

What versions are those systems running?  gcc --version (just need the version, not all of the output, thanks.)

My C9 instance report 4.4.7.

Title: Re: C Basic Class Library
Post by: kryton9 on November 11, 2013, 09:31:37 PM
Windows 7 output works fine. Lots of warnings however. Just copy what is listed in tiny size and paste in text editor, will be correct size then.
Quote
mingw32-gcc.exe -Wall  -O2     -c D:\8gb\CBasicClassLibrary\cp\Test.c -o obj\Release\Test.o
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:9:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\StringClass.c: In function 'StringFreeN':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:137:5: warning: statement with no effect [-Wunused-value]
D:\8gb\CBasicClassLibrary\cp\StringClass.c: In function 'StringSplit':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:398:7: warning: implicit declaration of function 'StringInstr' [-Wimplicit-function-declaration]
D:\8gb\CBasicClassLibrary\cp\StringClass.c: In function 'StringInsert':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:600:9: warning: unused variable 'w' [-Wunused-variable]
D:\8gb\CBasicClassLibrary\cp\StringClass.c: In function 'StringDelete':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:614:9: warning: unused variable 'w' [-Wunused-variable]
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:10:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\LexiClass.c: In function 'WordInfo':
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:50:5: warning: format '%i' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat]
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:51:5: warning: format '%i' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat]
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:52:5: warning: format '%i' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat]
D:\8gb\CBasicClassLibrary\cp\Test.c: At top level:
D:\8gb\CBasicClassLibrary\cp\Test.c:5:12: warning: return type defaults to 'int' [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'main':
D:\8gb\CBasicClassLibrary\cp\Test.c:81:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'TestStrings':
D:\8gb\CBasicClassLibrary\cp\Test.c:75:3: warning: control reaches end of non-void function [-Wreturn-type]
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:10:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'EndLine':
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:159:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'NextSpace':
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:142:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'WordShow':
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:60:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'WordInfo':
D:\8gb\CBasicClassLibrary\cp\LexiClass.c:53:3: warning: control reaches end of non-void function [-Wreturn-type]
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:9:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'StringAsc':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:671:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'StringShow':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:655:3: warning: control reaches end of non-void function [-Wreturn-type]
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:7:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'NewObject':
D:\8gb\CBasicClassLibrary\cp\GenericClass.c:200:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'Truncate':
D:\8gb\CBasicClassLibrary\cp\GenericClass.c:183:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'Shrink':
D:\8gb\CBasicClassLibrary\cp\GenericClass.c:171:3: warning: control reaches end of non-void function [-Wreturn-type]
D:\8gb\CBasicClassLibrary\cp\Test.c: In function 'Stretch':
D:\8gb\CBasicClassLibrary\cp\GenericClass.c:159:3: warning: control reaches end of non-void function [-Wreturn-type]
In file included from D:\8gb\CBasicClassLibrary\cp\BasicClassLibrary.h:9:0,
                 from D:\8gb\CBasicClassLibrary\cp\Test.c:3:
D:\8gb\CBasicClassLibrary\cp\StringClass.c: In function 'StringFreeN':
D:\8gb\CBasicClassLibrary\cp\StringClass.c:134:23: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
mingw32-g++.exe  -o bin\Release\cp.exe obj\Release\Test.o   -s 
Output size is 17.50 KB
Process terminated with status 0 (0 minutes, 3 seconds)
0 errors, 21 warnings (0 minutes, 3 seconds)
Title: Re: C Basic Class Library
Post by: kryton9 on November 11, 2013, 09:37:05 PM
Charles,

I'm working on getting the modified version of your code working on C9 and Red Hat is complaining on the run but not the compile.

allbasic@c_basic:~/668428/usr/john/cbc $ ./t_cbc
./t_cbc: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
allbasic@c_basic:~/668428/usr/john/cbc $

The same code runs fine on Ubuntu 64 bit.

John

I posted the same problem on c9 Blog a few days ago. From what I read, it is having conflicting versions of the same libs.
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 09:52:01 PM
Quote
I posted the same problem on c9 Blog a few days ago. From what I read, it is having conflicting versions of the same libs.

Charles only posted the his code here today so I'm not sure what you're saying.
Title: Re: C Basic Class Library
Post by: John on November 11, 2013, 11:05:59 PM
I was able to get all the .c source files fixed so CINT could run Charles new update. This is what CINT is saying ...

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbc $ cint -p Test.c
Warning: Automatic variable Free is allocated FILE:StringClass.c LINE:884
Warning: Automatic variable FreeN is allocated FILE:StringClass.c LINE:885
Warning: Automatic variable ArrayFree is allocated FILE:StringClass.c LINE:886
Warning: Automatic variable Copy is allocated FILE:StringClass.c LINE:887
Warning: Automatic variable GetChars is allocated FILE:StringClass.c LINE:888
Warning: Automatic variable SetChars is allocated FILE:StringClass.c LINE:889
Warning: Automatic variable GetMid is allocated FILE:StringClass.c LINE:890
Warning: Automatic variable SetMid is allocated FILE:StringClass.c LINE:891
Warning: Automatic variable Join is allocated FILE:StringClass.c LINE:893
Warning: Automatic variable Merge is allocated FILE:StringClass.c LINE:894
Warning: Automatic variable Split is allocated FILE:StringClass.c LINE:895
Warning: Automatic variable Repeat is allocated FILE:StringClass.c LINE:896
Warning: Automatic variable Replace is allocated FILE:StringClass.c LINE:897
Warning: Automatic variable Ucase is allocated FILE:StringClass.c LINE:898
Warning: Automatic variable Lcase is allocated FILE:StringClass.c LINE:899
Warning: Automatic variable Ltrim is allocated FILE:StringClass.c LINE:900
Warning: Automatic variable Rtrim is allocated FILE:StringClass.c LINE:901
Warning: Automatic variable Trim is allocated FILE:StringClass.c LINE:902
Warning: Automatic variable Insert is allocated FILE:StringClass.c LINE:903
Warning: Automatic variable Delete is allocated FILE:StringClass.c LINE:904
Warning: Automatic variable Chr is allocated FILE:StringClass.c LINE:905
Warning: Automatic variable Str is allocated FILE:StringClass.c LINE:906
Warning: Automatic variable Show is allocated FILE:StringClass.c LINE:907
Warning: Automatic variable Asc is allocated FILE:StringClass.c LINE:908
Warning: Automatic variable Cmp is allocated FILE:StringClass.c LINE:909
Warning: Automatic variable Instr is allocated FILE:StringClass.c LINE:910
Warning: Automatic variable Val is allocated FILE:StringClass.c LINE:911
Error: illegal pointer to class object vo 0x0 11  FILE:Test.c LINE:14
!!! return from main() function

cint>
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 12:11:47 AM
Something very strange is going on with C9. I'm getting the same error with my C BASIC simple demo. This compiled fine before. CINT isn't having a problem with it. ???

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cintbasic $ ./cb
./cb: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
allbasic@c_basic:~/668428/usr/john/cintbasic $
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 12:26:09 AM
The All BASIC C9 workspace is hosed. I went to another workspace and my cb.c example compile with gcc. I then tried Charles new class example.

Code: [Select]
scriptbasic@c9basic:~/642383/cbasic $ gcc Test.c -o teat1
In file included from BasicClassLibrary.h:9,
                 from Test.c:3:
StringClass.c:878: error: redefinition of typedef ‘StringClassTable’
StringClass.c:4: note: previous declaration of ‘StringClassTable’ was here
StringClass.c:878: error: redefinition of typedef ‘StringMethods’
StringClass.c:4: note: previous declaration of ‘StringMethods’ was here
scriptbasic@c9basic:~/642383/cbasic $ ./cb
1
2
3
4
5
x is now 6
My guess is 6
6
Double it up
scriptbasic@c9basic:~/642383/cbasic $

I tried both cb.c and Test.c on WinXP (VirtualBox) with MinGW32 (gcc version 4.7.1 (tdm-1)) and it worked without issue.

(http://files.allbasic.info/C_BASIC/cbclass.png)

Here is CINT under WinXP.

(http://files.allbasic.info/C_BASIC/cbcint.png)
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 01:36:29 AM
Thank you all for testing :)

I believe most of the problems are with line 4 in StringClass:

typedef struct StringClassTableStruct StringClassTable,*StringMethods;


It is a forward declaration for the ClassTable structure, which is defined following all the methods

I am using GCC 4.7.0

If this kind of declaration is unsupported by other versions of C then there is a compromise: make the String methods (void*) / ref

 class StringClassStruct
  begin
//BASE MEMBERS
  ref f;           // pointer to methods table
  int type;     // dynamic type code
  int offset;        // size of this header
  int nbytes;      // buffer ze for body of data
  int count;        // number of elements
  int size;           // size of each element
  end
  StringClass,*StringObject;


This compromises OOP notation, but its not serious, since it is generally more efficient to to work with dreferenced methods.

    ((StringMethods)vo->f)->Show(&vo); //ugh!

    dim as StringMethods f=vo->f; //methods

    f->SetChars(&uo,"LO");
...


I've update the zip here:
http://www.allbasic.info/forum/index.php?topic=283.msg3280#msg3280

Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 01:51:20 AM
Not there yet.

Code: [Select]
scriptbasic@c9basic:~/642383/cbclass $ gcc Test.c -o test
Test.c: In function ‘TestStrings’:
Test.c:14: warning: dereferencing ‘void *’ pointer
Test.c:14: error: request for member ‘Show’ in something not a structure or union
Test.c:15: warning: dereferencing ‘void *’ pointer
Test.c:15: error: request for member ‘SetChars’ in something not a structure or union
Test.c:16: warning: dereferencing ‘void *’ pointer
Test.c:16: error: request for member ‘SetChars’ in something not a structure or union
scriptbasic@c9basic:~/642383/cbclass $
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 02:13:19 AM
Can you try altering the first 2 offending lines in test.c

  //((StringMethods)vo->f)->Show(&vo); //ugh!

    dim as StringMethods f=(StringMethods) vo->f; //methods


(http://www.picturesof.net/_images_300/A_Man_Playing_Limbo_Royalty_Free_Clipart_Picture_090321-174670-445052.jpg)
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 02:40:09 AM
Okay, I made the change.


    // dim as StringMethods f=vo->f; //methods
    dim as StringMethods f=(StringMethods) vo->f; //methods

Code: [Select]
scriptbasic@c9basic:~/642383/cbclass $ gcc Test.c -o test
Test.c: In function ‘TestStrings’:
Test.c:14: warning: dereferencing ‘void *’ pointer
Test.c:14: error: request for member ‘Show’ in something not a structure or union
Test.c:15: warning: dereferencing ‘void *’ pointer
Test.c:15: error: request for member ‘SetChars’ in something not a structure or union
Test.c:16: warning: dereferencing ‘void *’ pointer
Test.c:16: error: request for member ‘SetChars’ in something not a structure or union
scriptbasic@c9basic:~/642383/cbclass $

I don't think that changed anything.

I'm on chat if that would speed things along. (I'm fading fast 2:45 am here)
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 02:48:59 AM
Which gcc are you using John? my 4.7.0 does not protest.
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 02:51:29 AM
I posted them here. (http://www.allbasic.info/forum/index.php?topic=283.msg3298#msg3298)

If works fine on Ubuntu. Only Red Hat / CentOS are complaining. AIR is having issue on OSX.
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 03:02:59 AM
No further ideas here. Sleep well!

---

Does MacOsx or RedHat have problems with CRLF  (ascii 13,10) line formats?
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 03:10:05 AM
Here is the error report trying to compile it on Android. (with latest fix)

Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 03:32:48 AM
Re: compiling on John's Android:

I have fixed the forward reference to StringInstr by moving ths function up the ladder.

and removed the vo->f-> thing.

http://www.allbasic.info/forum/index.php?topic=283
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 10:45:37 AM
Charles,

The latest build works on C9 Red Hat 64 bit. I will test it with CINT and Android. Thanks!

Code: [Select]
scriptbasic@c9basic:~/642383/cbclass $ gcc Test.c -o test1
scriptbasic@c9basic:~/642383/cbclass $ ./test1
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
   \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 13111506
Word End:   13111508
Text End:   13111512
=
scriptbasic@c9basic:~/642383/cbclass $

I gave cint a try in the busted workspace and we seem to have only one issue left. Until I try this in a good workspace or using the WinXP version CINT, use this info with caution.

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: illegal pointer to class object vo 0x0 10  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>

Update

I got the All BASIC C9 workspace GCC working again. The problem was a C9 gcc wrapper package that I installed to see if it would solve our RH issues with gcc but caused more problems than it solved.

Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 11:49:12 AM
Working in RedHet: excellent!

Strange that CINT refers to the word 'class', since vo is instantiated from a type (after preprocessing). Are we interfering with it's namespace here?
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 11:52:47 AM
I would need to revisit the CINT limitations doc I posted to see why your code isn't working. At least the auto vars went away in cint.

The only thing I can think of that might be causing the problem is the * (PTR) required space in cint. I will do a DIFF of your current version and my cint friendly version and see if that resolves the problem.
Title: C Basic Class Library - Android
Post by: John on November 12, 2013, 01:46:04 PM
(http://files.allbasic.info/C_BASIC/cbclassdroid.png)

jrs@laptop:~/C_BASIC/cbclass$ adb install cbclass.apk
2232 KB/s (332926 bytes in 0.145s)
   pkg: /data/local/tmp/cbclass.apk
Success
jrs@laptop:~/C_BASIC/cbclass$


Note: Attached is the above you can try on your Android device.
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 02:36:28 PM

So the rules are:

No forward references to a procedure without an explicit declaration

No typedef declarations. The full typedef has to be specified before any code that uses it.


Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 02:38:49 PM
Does this mean you solved the cint issue?
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 12, 2013, 09:38:21 PM
I see from the docs that CINT is c++. It looks like a class conflict. :)

Posted a new version that uses the word types instead of class.

http://www.allbasic.info/forum/index.php?topic=283
Title: Re: C Basic Class Library
Post by: John on November 12, 2013, 10:38:07 PM
CINT is an ANSI/ISO C complaint interpreter. The C++ extensions aren't feature rich. CLING is using CLANG which is a C++ only interpreter. The new 6.0 version of ROOT will be based on CLING.

Results
Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: illegal pointer to class object vo 0x0 9  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>

I noticed in the CINT MAN page (http://manpages.ubuntu.com/manpages/lucid/man1/cint.root.1.html) that the -K option forces C interpretation.

Quote
-K     C mode

Handles given file as C, regardless of file extension. Otherwise, .c files are handled as C and .cxx, .C and .cpp files are handled as C++.

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -K -p Test.c
Error: illegal pointer to class object vo 0x0 9  FILE:Test.c LINE:18
Error: illegal type cast (2) FILE:Test.c LINE:18
!!! return from main() function

cint>
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 01:28:50 AM
Somehow we must get it to swallow this pill.

how about:

dim as StringMethods f=(StringMethods) (0+vo->f);
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 02:23:26 AM
Quote
dim as StringMethods f=(StringMethods) (0+vo->f);


Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p Test.c
Error: Symbol vo is not defined in current scope  FILE:StringClass.c LINE:39
Error: Failed to evaluate vo->f
Error: class,struct,union or type StringMethods not defined  FILE:StringClass.c LINE:39
Error: Invalid type 'StringMethods' in declaration of 'f' FILE:StringClass.c LINE:39
allbasic@c_basic:~/668428/usr/john/cbclass $

I have attached the Windows 32 bit binary version of cint . Just point your PATH to the cint base directory. For whatever reason MinGW didn't seem to work. I use the MS VC10 compiler that comes with the Windows SDK 7.

Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 02:40:36 AM
This error message does not make sense. It refers to a blank line (39) in stringclass.c :)
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 02:53:21 AM
Looks the same to me running on Windows XP using MS VC10 console.

The first run is virgin ZIP and the second is the last change you suggested.

Code: [Select]
F:\cbclass>cint -p Test.c
Test.c
Error: illegal pointer to class object vo 0x0 10  Test.c(18)
Error: illegal type cast (2) Test.c(18)
!!! return from main() function

cint> q
  Bye... (try 'qqq' if still running)

F:\cbclass>cint -p Test.c
Test.c
Error: Symbol vo is not defined in current scope  f:\cbclass\stringclass.c(40)
Error: Failed to evaluate vo->f
Error: class,struct,union or type StringMethods not defined  f:\cbclass\stringclass.c(40)
Warning: Automatic variable StringMethods f is allocated f:\cbclass\stringclass.c(40)

F:\cbclass>
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 03:33:21 AM
Before anyone asks why are we trying to shotgun debug a debugger, maybe you could download the Windows version I attached and set your PATH to where you unziped it and run it in a VC10 console. I have been showing it run like it was a SB script. Start cint, load the program, set what break points you need and step through the code viewing variables along the way. If we are unwilling to use cint to debug C BASIC code, trying to package it as a tool with C BASIC seems like a waste of our time.

It's late and I'm tired. Good-night.

Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 03:42:13 AM
Thanks John, I'll play with VC10 first and deal with any issues there. CINT compatibility further down the list. Sleep well.
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 03:46:45 AM
You could always use my trusty Got Here! debugger.  ;D

This is what cint reports when I load the Test.c program from within cint. This tells me that it's not an execution issue but a syntactical problem cint is having with the code. My guess is that your doing something beyond the capabilities of the interpreter.

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cbclass $ cint -p

cint : C/C++ interpreter  (mailing list 'cint@root.cern.ch')
   Copyright(c) : 1995~2010 Masaharu Goto (gotom@hanno.jp)
   revision     : 5.18.00, July 2, 2010 by M.Goto

No main() function found in given source file. Interactive interface started.
'h':help, 'q':quit, '{statements;}' or 'p [expr]' to evaluate

cint> L Test.c
Error: Symbol vo is not defined in current scope  FILE:StringClass.c LINE:39
Error: Failed to evaluate vo->f
Error: class,struct,union or type StringMethods not defined  FILE:StringClass.c LINE:39
Error: Invalid type 'StringMethods' in declaration of 'f' FILE:StringClass.c LINE:39
!!!Error recovered!!!
cint>

This is a simple debugging session using my cb.c C BASIC example. Notice how the #defines are expanded during the debugging session?

Code: [Select]
allbasic@c_basic:~/668428/usr/john/cintbasic $ cint -p

cint : C/C++ interpreter  (mailing list 'cint@root.cern.ch')
   Copyright(c) : 1995~2010 Masaharu Goto (gotom@hanno.jp)
   revision     : 5.18.00, July 2, 2010 by M.Goto

No main() function found in given source file. Interactive interface started.
'h':help, 'q':quit, '{statements;}' or 'p [expr]' to evaluate

cint> L cb.c
cint> p main(0,0);
1
2
3
4
5
x is now 6
My guess is 6
6
Double it up
cint> q
  Bye... (try 'qqq' if still running)
allbasic@c_basic:~/668428/usr/john/cintbasic $

...

cint> p main();

# cb.c
3    main()
4    {
5      int x;
6      for (x = 1 ;
FILE:cb.c LINE:6 cint> s
 x < 6 ; ++ x)
FILE:cb.c LINE:6 cint> s

7      {
8        printf ("%i\n",x);
FILE:cb.c LINE:8 cint> s
1

9      }
7      {
8        printf ("%i\n",x);
FILE:cb.c LINE:8 cint> s
2

9      }
7      {
8        printf ("%i\n",x);
FILE:cb.c LINE:8 cint> s
3

9      }
7      {
8        printf ("%i\n",x);
FILE:cb.c LINE:8 cint> s
4

9      }
7      {
8        printf ("%i\n",x);
FILE:cb.c LINE:8 cint> s
5

9      }
10     if (x == 6)
FILE:cb.c LINE:10 cint> s
 printf ("x is now 6\n");
FILE:cb.c LINE:10 cint> s
x is now 6

11     if (x > 5 && x < 7)
FILE:cb.c LINE:11 cint> s
 {
12       printf ("My guess is 6\n");
FILE:cb.c LINE:12 cint> s
My guess is 6

13     } else
16     int y = 0;
17     do {
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     } while (y < x)
FILE:cb.c LINE:19 cint> s
{
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     }
FILE:cb.c LINE:19 cint> s
{
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     }
FILE:cb.c LINE:19 cint> s
{
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     }
FILE:cb.c LINE:19 cint> s
{
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     }
FILE:cb.c LINE:19 cint> s
{
18       ++ y;
FILE:cb.c LINE:18 cint> s

19     }
FILE:cb.c LINE:19 cint> s
 while (y < x);
20     printf ("%i\n", y);
FILE:cb.c LINE:20 cint> s
6

21     x += y;
FILE:cb.c LINE:21 cint> s

22     switch (x)
FILE:cb.c LINE:22 cint> s

23     {      printf ("Double it up\n");
FILE:cb.c LINE:30 cint> s
Double it up

31         break;
FILE:cb.c LINE:31 cint> s

35   }cint> s

cint>
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 08:38:30 AM
I agree that we should put CINT aside and revisit it as an option when time permits. My conCERNs are that cint is being phased out for a C++ only solution. (CLING) As much as I would like to have an interpreter/debugger to compliment the C BASIC offering, it's taking too much time from more important aspects of this project.


Title: C Basic Class Library - BASIC string functions
Post by: John on November 13, 2013, 11:14:15 AM
Charles,

Can you post a few examples of #define(s) that I can use in my keyword table?

DIM AS STRING w;

#define UCASE
#define MID
#define LEFT
#define INSTR

This will help me understand how strings are created and manipulated with string functions.
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 12:03:06 PM
Hi John,

Bypassing OOP function tables, where A is the target StringObject, and B is the source. (A and B can be the same)

#define UCASE(A,B) StringUcase(&A,B)

similar here

#define MID(A,B,C,D) StringGetMid(&A,B,C,D)


I am embroiled in further strictures to make the library compile with VC10.
:o
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 01:04:45 PM
I'm assuming this will work like the object version I did before?

#define UCASE(x) StringUcase(&x, x)

How do I emulate a DIM AS STRING like #define. Is there only one kind of string in C BASIC?
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 02:11:18 PM

yes you can UCASE to self, as with most of the other string functions.



    dim as StringObject  wo=NewString(100);

    #define STRING StringObject

  DIM AS STRING wo=NewString(100) //suitable approx buffer size
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 05:23:41 PM
For grins, I thought I would try the C BASIC Test.c with CLING. Interesting results.

Code: [Select]
jrs@laptop:~/C_BASIC/cbclass$ cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ .L Test.c
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:3:
In file included from ./BasicClassLibrary.h:6:
./BasicDefine.h:13:11: error: C++ operator 'and' cannot be used as a macro name
  #define and   &&
          ^
./BasicDefine.h:14:11: error: C++ operator 'or' cannot be used as a macro name
  #define or    ||
          ^
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:3:
In file included from ./BasicClassLibrary.h:7:
./BasicSpace.c:32:11: error: cannot initialize a variable of type 'char *' with an rvalue of type 'void *'
    char *v =  malloc(count);
          ^    ~~~~~~~~~~~~~
./BasicSpace.c:41:10: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
    char*s=sv;
         ^ ~~
./BasicSpace.c:42:10: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
    char*t=tv;
         ^ ~~
./BasicSpace.c:74:10: error: cannot initialize a variable of type 'char *' with an rvalue of type 'void *'
    char*t=malloc(n);
         ^ ~~~~~~~~~
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:3:
In file included from ./BasicClassLibrary.h:8:
./GenericClass.c:55:42: error: expected ')'
  sub            SetObjectHeader (Object this,ref f,int le, int wi,int so);
                                         ^
./GenericClass.c:55:34: note: to match this '('
  sub            SetObjectHeader (Object this,ref f,int le, int wi,int so);
                                 ^
./GenericClass.c:73:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:84:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:96:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:106:30: error: expected ')'
  sub SetObjectHeader(Object this,ref f,int le, int wi,int so)
                             ^
./GenericClass.c:106:22: note: to match this '('
  sub SetObjectHeader(Object this,ref f,int le, int wi,int so)
                     ^
./GenericClass.c:108:5: error: invalid use of 'this' outside of a non-static member function
    this->f      = f;
    ^
./GenericClass.c:108:20: error: use of undeclared identifier 'f'
    this->f      = f;
                   ^
./GenericClass.c:109:5: error: invalid use of 'this' outside of a non-static member function
    this->offset = so;
    ^
./GenericClass.c:109:20: error: use of undeclared identifier 'so'
    this->offset = so;
                   ^
./GenericClass.c:110:5: error: invalid use of 'this' outside of a non-static member function
    this->nbytes = le*wi;
    ^
./GenericClass.c:110:20: error: use of undeclared identifier 'le'
    this->nbytes = le*wi;
                   ^
./GenericClass.c:110:23: error: use of undeclared identifier 'wi'
    this->nbytes = le*wi;
                      ^
./GenericClass.c:111:5: error: invalid use of 'this' outside of a non-static member function
    this->count  = le;
    ^
fatal error: too many errors emitted, stopping now
[cling]$
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 10:40:57 PM

I have downgraded the code to make it compatible with VC10, as well as GCC 6.7. It might be more palatable for other compilers too, since it is very plain C, with all variables declared first, no scopes, and no case ranges.

http://www.allbasic.info/forum/index.php?topic=283

Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 10:46:43 PM
Hi Charles,

Your latest compiled/ran fine on Ubuntu 64 bit but Cling still doesn't like you.  :(

Code: [Select]
jrs@laptop:~/C_BASIC/cbclass$ gcc Test.c -o test4
jrs@laptop:~/C_BASIC/cbclass$ ./test4
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
       \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 38289618
Word End:   38289620
Text End:   38289624
=
jrs@laptop:~/C_BASIC/cbclass$ cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ .L Test.c
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:2:
In file included from ./BasicClassLibrary.h:6:
./BasicDefine.h:13:11: error: C++ operator 'and' cannot be used as a macro name
  #define and   &&
          ^
./BasicDefine.h:14:11: error: C++ operator 'or' cannot be used as a macro name
  #define or    ||
          ^
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:2:
In file included from ./BasicClassLibrary.h:7:
./BasicSpace.c:41:10: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
    char*s=sv;
         ^ ~~
./BasicSpace.c:42:10: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
    char*t=tv;
         ^ ~~
In file included from -:1:
In file included from input_line_4:1:
In file included from ./Test.c:2:
In file included from ./BasicClassLibrary.h:8:
./GenericClass.c:55:42: error: expected ')'
  sub            SetObjectHeader (Object this,ref f,int le, int wi,int so);
                                         ^
./GenericClass.c:55:34: note: to match this '('
  sub            SetObjectHeader (Object this,ref f,int le, int wi,int so);
                                 ^
./GenericClass.c:73:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:85:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:98:12: error: cannot initialize a variable of type 'Object' (aka 'ClassStruct *') with an lvalue of type 'void *'
    Object t=*pt;
           ^ ~~~
./GenericClass.c:109:30: error: expected ')'
  sub SetObjectHeader(Object this,ref f,int le, int wi,int so)
                             ^
./GenericClass.c:109:22: note: to match this '('
  sub SetObjectHeader(Object this,ref f,int le, int wi,int so)
                     ^
./GenericClass.c:111:5: error: invalid use of 'this' outside of a non-static member function
    this->f      = f;
    ^
./GenericClass.c:111:20: error: use of undeclared identifier 'f'
    this->f      = f;
                   ^
./GenericClass.c:112:5: error: invalid use of 'this' outside of a non-static member function
    this->offset = so;
    ^
./GenericClass.c:112:20: error: use of undeclared identifier 'so'
    this->offset = so;
                   ^
./GenericClass.c:113:5: error: invalid use of 'this' outside of a non-static member function
    this->nbytes = le*wi;
    ^
./GenericClass.c:113:20: error: use of undeclared identifier 'le'
    this->nbytes = le*wi;
                   ^
./GenericClass.c:113:23: error: use of undeclared identifier 'wi'
    this->nbytes = le*wi;
                      ^
./GenericClass.c:114:5: error: invalid use of 'this' outside of a non-static member function
    this->count  = le;
    ^
./GenericClass.c:114:20: error: use of undeclared identifier 'le'
    this->count  = le;
                   ^
./GenericClass.c:115:5: error: invalid use of 'this' outside of a non-static member function
    this->size  = wi;
    ^
fatal error: too many errors emitted, stopping now
[cling]$
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 13, 2013, 10:55:39 PM
Yes we intrude on its own C++ namespace.
Title: Re: C Basic Class Library
Post by: John on November 13, 2013, 11:12:39 PM
To put that in terms I can understand, are you saying that your code is being seen by Cling as C with C++ attributes?

C9 Red Hat

allbasic@c_basic:~/668428/usr/john/cb_class $ gcc Test.c -o test1
allbasic@c_basic:~/668428/usr/john/cb_class $ ./test1
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
   \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 14966994
Word End:   14966996
Text End:   14967000
=
allbasic@c_basic:~/668428/usr/john/cb_class $

Since Cling thinks it's a hotshot C++ interpreter now, I thought I would test your current code on the old CINT standard.

allbasic@c_basic:~/668428/usr/john/cb_class $ cint -p Test.c
Error: Can't call StringClassTableStruct::SetChars(&uo,"LO") in current scope FILE:Test.c LINE:23
Possible candidates are...
(in StringClassTableStruct)
!!! return from main() function

cint>

I thought :: was C++ style code.
Title: Re: C Basic Class Library
Post by: John on November 14, 2013, 12:45:45 AM
Dynamic Strings in C

What is the downside of using a dynamic string scheme like THIS (http://locklessinc.com/articles/dynamic_cstrings/)?

<string.h> seems to have most of the string manipulation routines in its library.
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 14, 2013, 03:17:24 AM
String.h is okay for null terminated ascii strings.

The string object defined in StringClass.h has length and char width attributes, and automatic buffering. - more like a Basic string

http://pubs.opengroup.org/onlinepubs/007908775/xsh/string.h.html
Title: Re: C Basic Class Library
Post by: John on November 14, 2013, 10:00:42 AM
When I concatenate a string with the new library, do I have to worry about string lengths? Keep in mind I have been spoiled by SB so it's going to be weird having to deal with this again.

Title: Re: C Basic Class Library
Post by: Charles Pegge on November 14, 2013, 10:58:24 AM
No, the only thing left to do is free the strings before they go out of scope. There isn't an automatic garbage collector. (Yet)
Title: Re: C Basic Class Library
Post by: John on November 14, 2013, 11:03:13 AM
Quote
There isn't an automatic garbage collector. (Yet)

I have held that role in my family for years.  ::)

Make money programming in Freebasic (http://www.freebasic.net/forum/viewtopic.php?f=17&t=21746)

Maybe someone should tell them about JADE.
Title: Re: C Basic Class Library
Post by: John on November 15, 2013, 10:54:40 AM
Charles,

I haven't heard you mention that your tried your C BASIC class library with Windows 64 bit yet. I was doing my once a month updates of Windows 7 64 bit and while there I thought I would give it a try. I used MinGW-TDM64 and it seems to works fine and no additional compiler switches needed.

(http://files.allbasic.info/C_BASIC/cbclass64.png)
Title: Re: C Basic Class Library
Post by: John on November 15, 2013, 11:31:55 AM
AIR,

Is C development on OSX something nobody does? Based on my observations and your previous comments about IUP on that platform, would the C BASIC project be wasting your time testing there?
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 15, 2013, 02:18:39 PM
I tested on windows gcc 32bit and 64 bit. We are unlikely to see further 64 bit issues, though some caution is needed when storing data to file with unpacked structures. These potentially differ, causing file incompatibility.
Title: Re: C Basic Class Library
Post by: John on November 15, 2013, 02:52:26 PM
Thanks for the update Charles and I will assume you are covering the Windows 32/64 bit front with both gcc & VC####. I'll make sure things run on Linux 32/64 bit and Android. I don't own or have access to any Apple products.

My next effort is to create a C to C BASIC translator. Doing this by hand is getting old.  :-\
Title: Re: C Basic Class Library
Post by: AIR on November 15, 2013, 07:48:10 PM
AIR,

Is C development on OSX something nobody does? Based on my observations and your previous comments about IUP on that platform, would the C BASIC project be wasting your time testing there?

C is used all the time, you can intermix C and Objective C with no problems.

IUP's GTK Dependency pretty much kills it's use on OSX.
Title: Re: C Basic Class Library
Post by: John on November 15, 2013, 08:09:13 PM
Thanks for the good news!

Were you able to get Charles's current C BASIC class library to compile and run on OSX?

Did the Cling binary version for OSX 10.x work on your box?

Title: Re: C Basic Class Library
Post by: AIR on November 17, 2013, 12:03:54 PM
It compiles and runs, with a bunch of warnings (turn on -Wall to see so you/he can fix them).

Quote
In file included from Test.c:2:
In file included from ./BasicClassLibrary.h:10:
./StringClass.c:543:5: warning: expression result unused [-Wunused-value]
    e;                 // boundary of string segment
    ^
./StringClass.c:544:5: warning: expression result unused [-Wunused-value]
    le;                // length of string segment
    ^~
./StringClass.c:545:5: warning: expression result unused [-Wunused-value]
    d;                 // stride for next string segment
    ^
In file included from Test.c:2:
In file included from ./BasicClassLibrary.h:11:
./LexiClass.c:50:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word Start: %i\n",w->bp);
                        ~~    ^~~~~
                        %s
./LexiClass.c:51:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Word End:   %i\n",w->ep);
                        ~~    ^~~~~
                        %s
./LexiClass.c:52:31: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
    printf("Text End:   %i\n",w->et);
                        ~~    ^~~~~
                        %s
./LexiClass.c:100:7: warning: comparison of constant 255 with expression of type 'char' is always true
      [-Wtautological-constant-out-of-range-compare]
      IfRange(33,a,255) {w->xx |= IsWord; break;}
      ^          ~ ~~~
./LexiClass.c:91:40: note: expanded from macro 'IfRange'
  #define IfRange(A,B,C) if ((A<=B)&&(B<=C))
                                       ^
./LexiClass.c:115:7: warning: comparison of constant 255 with expression of type 'char' is always true
      [-Wtautological-constant-out-of-range-compare]
      IfRange(33,a,255)    {w->xx |= IsWord;    break;}
      ^          ~ ~~~
./LexiClass.c:91:40: note: expanded from macro 'IfRange'
  #define IfRange(A,B,C) if ((A<=B)&&(B<=C))
                                       ^
Test.c:5:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  function TestStrings()
           ^~~~~~~~~~~
Test.c:80:3: warning: control reaches end of non-void function [-Wreturn-type]
  end
  ^
./BasicDefine.h:12:17: note: expanded from macro 'end'
  #define end   }
                ^
10 warnings generated.
Title: Re: C Basic Class Library
Post by: John on November 17, 2013, 12:16:06 PM
Charles and I don't have a Mac to test on. Were aren't seeing these issues on Windows, Linux or Android. You are the Mac expert and we are counting on you to support that platform. It would be great if you could help Charles along with making his code more OSX compatible.
Title: Re: C Basic Class Library
Post by: John on November 17, 2013, 01:25:56 PM
I take that back. Here is the warnings gcc returns with -Wall on Ubuntu 64 bit.

C BASIC class Libraries
Code: [Select]
jrs@laptop:~/C_BASIC/cbclass$ gcc -Wall Test.c -o test4errors
In file included from BasicClassLibrary.h:10:0,
                 from Test.c:2:
StringClass.c: In function ‘StringMerge’:
StringClass.c:469:9: warning: unused variable ‘wn’ [-Wunused-variable]
     int wn,en,ne,i,tot,wid,kl;
         ^
StringClass.c: In function ‘StringSplit’:
StringClass.c:543:5: warning: statement with no effect [-Wunused-value]
     e;                 // boundary of string segment
     ^
StringClass.c:544:5: warning: statement with no effect [-Wunused-value]
     le;                // length of string segment
     ^
StringClass.c:545:5: warning: statement with no effect [-Wunused-value]
     d;                 // stride for next string segment
     ^
In file included from BasicClassLibrary.h:11:0,
                 from Test.c:2:
LexiClass.c: In function ‘WordInfo’:
LexiClass.c:50:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Word Start: %i\n",w->bp);
     ^
LexiClass.c:51:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Word End:   %i\n",w->ep);
     ^
LexiClass.c:52:5: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘char *’ [-Wformat=]
     printf("Text End:   %i\n",w->et);
     ^
Test.c: At top level:
Test.c:5:12: warning: return type defaults to ‘int’ [-Wreturn-type]
   function TestStrings()
            ^
Test.c: In function ‘TestStrings’:
Test.c:80:3: warning: control reaches end of non-void function [-Wreturn-type]
   end
   ^
Test.c: In function ‘main’:
Test.c:86:3: warning: control reaches end of non-void function [-Wreturn-type]
   end
   ^
jrs@laptop:~/C_BASIC/cbclass$

C BASIC w/keyword list only
Code: [Select]
jrs@laptop:~/C_BASIC/cintbasic$ gcc -Wall cb.c -o cbtest4errors
jrs@laptop:~/C_BASIC/cintbasic$ ./cbtest4errors
1
2
3
4
5
x is now 6
My guess is 6
6
Double it up
jrs@laptop:~/C_BASIC/cintbasic$

SDL sprite - Ubuntu 64
Code: [Select]
jrs@laptop:~/C_BASIC/xlate$ gcc -Wall -g -O2 testsprite.c -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL -L/usr/lib/x86_64-linux-gnu -lSDL -o testsprite
jrs@laptop:~/C_BASIC/xlate$
Title: Re: C Basic Class Library
Post by: AIR on November 17, 2013, 03:34:04 PM
Charles and I don't have a Mac to test on. Were aren't seeing these issues on Windows, Linux or Android. You are the Mac expert and we are counting on you to support that platform. It would be great if you could help Charles along with making his code more OSX compatible.

It's not an OS issue, it's a CODING issue.  If you eliminate the warnings (or errors, if they occur) then you should be able to build successfully on any platform that the GNU Compiler Collection supports, with the only caveat being that you need to be aware that not all OS's support all header files (handled by judiciously using IFDEF's).
Title: Re: C Basic Class Library
Post by: John on November 17, 2013, 03:59:41 PM
I'm leaving / incorporating the #include files as part of the main program. I understand there a standard set of includes that go along with most C/C++ programs. I plan on only having a cbasic.h that covers #define(s) and BASIC runtime functions. (including a subset of Charles's class files) I want to get a solid traditional C BASIC working before taking on OOP.

Title: Re: C Basic Class Library
Post by: AIR on November 17, 2013, 06:04:39 PM
It's not about OOP, though.

If you're ever porting a C/C++ program from one platform to another, there are certain core headers that are not available on certain platforms.  So you have to account for that.  Certain headers on Linux, for example, that don't exist in MinGW for Windows.  Or Functions that are valid in Windows that don't exist elsewhere (not talking about WinApi, but generic C functions that Microsoft provides-like itoa() ).

Stuff like that is what someone hoping to provide a cross-platform solution has to be aware of.  And account for.

This hasn't come up in your implementation yet.  But it's possible that it will down the line, so I'm just making you aware...
Title: Re: C Basic Class Library
Post by: John on November 17, 2013, 11:58:44 PM
Based on our discussions off line, OSX doesn't support a cross platform GUI toolkit worth using. Apple once again has defined their own standards and not willing to share their API on non-Apple products. Just like not being able to run OSX on non-Apple hardware. (legally) They have become an island and worse than Microsoft in this area. This is why I don't own any Apple products or develop exclusively for the platform.

I'm going to take your advice and not spend any effort on Apple until IUP has a native Cocoa GUI version. (the IUP folks don't seem too motivated and I can see why)

Quote from: IUP site
Why Not Mac? The first Mac driver was developed for MacOS 9 and had several memory limitations so it was abandoned. With Mac OS X we have the opportunity to do something better. Today IUP runs on Mac OS X using X11 with Motif or GTK. We plan for the future to build a native driver, but it is not a Tecgraf priority.

@AIR - I noticed that your Tiny Times JADE Qt4 example was done on the Mac. Is Qt for the Mac a viable cross platform solution?
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 18, 2013, 12:56:03 AM
Thanks Armando and John, I have fixed those warnings.

http://www.allbasic.info/forum/index.php?topic=283

We might be able to engage with OSX at the Opengl Level. I've invested some time in exploring OpenGL-GUI possibilities. All the controls have to be created from scratch, of course, which is either heaven or hell, depending on your coding and design interests :)
Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 01:19:41 AM
It compiles and runs but now gives warnings with or without -Wall

Should we standardize on <stdint.h> (and other std libs) C provides for a smooth 32 to 64 bit migration?

Code: [Select]
jrs@laptop:~/C_BASIC/cbclass/20131118$ gcc -Wall Test.c -o cbgcc
In file included from BasicClassLibrary.h:11:0,
                 from Test.c:2:
LexiClass.c: In function ‘WordInfo’:
LexiClass.c:50:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Word Start: %i\n",(int)w->bp);
                               ^
LexiClass.c:51:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Word End:   %i\n",(int)w->ep);
                               ^
LexiClass.c:52:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Text End:   %i\n",(int)w->et);
                               ^
jrs@laptop:~/C_BASIC/cbclass/20131118$ gcc Test.c -o cbgcc
In file included from BasicClassLibrary.h:11:0,
                 from Test.c:2:
LexiClass.c: In function ‘WordInfo’:
LexiClass.c:50:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Word Start: %i\n",(int)w->bp);
                               ^
LexiClass.c:51:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Word End:   %i\n",(int)w->ep);
                               ^
LexiClass.c:52:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     printf("Text End:   %i\n",(int)w->et);
                               ^
jrs@laptop:~/C_BASIC/cbclass/20131118$ ./cbgcc
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
       \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 19972306
Word End:   19972308
Text End:   19972312
=
jrs@laptop:~/C_BASIC/cbclass/20131118$
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 18, 2013, 01:40:28 AM
That's curious. It's okay on 32bit gcc (4.7.0) but shows up on 64 bit.

Using %p instead of %i should fix it.

    printf("Word Start: %p\n",w->bp);
    printf("Word End:   %p\n",w->ep);
    printf("Text End:   %p\n",w->et);
Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 01:59:55 AM
What file are these lines in? They aren't in the Test.c file.

grep isn't working for me for some reason and gives me a > prompt no matter what I try.  :-\
Title: Re: C Basic Class Library
Post by: Charles Pegge on November 18, 2013, 02:02:37 AM
They are in LexiClass.c. I've reposted now.

http://www.allbasic.info/forum/index.php?topic=283
Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 02:05:59 AM
I was able to find it with grep finally. The embedded quote got me.

Code: [Select]
jrs@laptop:~/C_BASIC/cbclass/20131118$ gcc Test.c -o cbgcc
jrs@laptop:~/C_BASIC/cbclass/20131118$ gcc -Wall Test.c -o cbgcc
jrs@laptop:~/C_BASIC/cbclass/20131118$ ./cbgcc
LO
HELLO
HELLOHELLOHELLO
9
helloLOhellohello
hellohellohello
42.000000
42.000000
AbcAbcAbcAbcAbcAbcAbc
LOLOLOLOLOLOLO
AbcAbcAbcAbcAbcAbcAbc
<
>
  Hello World!
<HELLO WORLD!>
<<HELLO WORLD!>>
HELLO
HELLOH
abc
       \abc
WORD:       aa
Class Size: 80
Char Width: 1
Word Len:   2
Word Start: 0x171e0d2
Word End:   0x171e0d4
Text End:   0x171e0d8
=
jrs@laptop:~/C_BASIC/cbclass/20131118$

Looks good Charles!

FYI: I gave it a try with g++. Needless to say I can understand why ROOT dislikes you so much.  ;D
Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 02:18:14 AM
Quote
We might be able to engage with OSX at the Opengl Level. I've invested some time in exploring OpenGL-GUI possibilities.

I'm surprised no one has done a SDL X11 yet. They did a great job with DOSBox using SDL, a cross platform GUI seems like a natural. Seems Qt has the lead in this area. I can run Qt form based apps on Android now.

(http://www.allbasic.info/forum/index.php?action=dlattach;topic=210.0;attach=484;image)
Title: Re: C Basic Class Library
Post by: AIR on November 18, 2013, 05:49:01 AM
Based on our discussions off line, OSX doesn't support a cross platform GUI toolkit worth using. Apple once again has defined their own standards and not willing to share their API on non-Apple products. Just like not being able to run OSX on non-Apple hardware. (legally) They have become an island and worse than Microsoft in this area. This is why I don't own any Apple products or develop exclusively for the platform.

Talk to me when Microsoft makes their GUI legally available on other platforms.

Quote
I'm going to take your advice and not spend any effort on Apple until IUP has a native Cocoa GUI version. (the IUP folks don't seem too motivated and I can see why)

Quote from: IUP site
Why Not Mac? The first Mac driver was developed for MacOS 9 and had several memory limitations so it was abandoned. With Mac OS X we have the opportunity to do something better. Today IUP runs on Mac OS X using X11 with Motif or GTK. We plan for the future to build a native driver, but it is not a Tecgraf priority.

Illustrating the point I was making to you, that implementing something like this is NOT A SIMPLE MATTER! 

I never advised you not to look into Apple, btw. 

Quote
@AIR - I noticed that your Tiny Times JADE Qt4 example was done on the Mac. Is Qt for the Mac a viable cross platform solution?

Yes, that's the reason that I provided that demo. 
Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 10:40:34 AM
Quote
Talk to me when Microsoft makes their GUI legally available on other platforms.

I can run Windows applications on Wine legally. I can run XP in a VirtualBox. The bottom line is even though Windows isn't my platform of choice, I can still create programs for it without having to buy some over priced hardware that caters to appliance based users.

Title: Re: C Basic Class Library
Post by: AIR on November 18, 2013, 01:52:55 PM
Take the time to actually read what I said.  I didn't say APPLICATIONS, I said their GUI.  In response to what you were saying about Apple not making their API available on other platforms.

Emulation is not the same as making the API available across the board.  Last time I checked, Wine was not a Microsoft Product.

This is a dumb discussion anyway, because both companies are in the business of making money, and don't care what we might think.

I chose Apple, simply because my background is in UNIX, on the command line, and that is what OS X is built on. 

Anyway, we've derailed this thread enough.  If you want to continue this discussion, you know how to reach me.

Oh, and take a look at the screenshot on your way out....this is my PC workstation at the job...




Title: Re: C Basic Class Library
Post by: John on November 18, 2013, 02:07:17 PM
PLEASE take your work system down to shipping and tell them you're sending out for repair. (I will send you my shipping address in a private e-mail) I will respond to your company in a month or so indicating that your system was a total loss and not worth repairing. After a couple days of being without a system and your productivity dropping drastically, they will buy you a new and better Apple system and in the end we all will be better off for your efforts.  :-*

You could be Santa this year.  ;D

Seriously, I don't know why companies/employees don't get together during the holiday season and put together PC care packages of outdated gear that could give some kid an early chance (http://www.thinbasic.com/community/showthread.php?t=12277&p=90252&viewfull=1#post90252) at computing.