home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 350.lha / DEdit_v2.01 / LibTest.c < prev    next >
C/C++ Source or Header  |  1990-02-25  |  2KB  |  83 lines

  1. /*********************************************************************
  2.  * LibTest.c
  3.  *
  4.  * Test program for string.library
  5.  *
  6.  *********************************************************************/
  7.  
  8. #include    <exec/types.h>
  9. #include    <exec/libraries.h>
  10. #include    <graphics/display.h>
  11. #include    <intuition/intuition.h>
  12. #include    <libraries/stringlib.h>
  13.  
  14.  
  15. char Bstr[] = { 0x12,'T','h','i','s',' ','i','s',' ','a',' ','B','s','t','r','i','n','g','.' };
  16. char TestStr[] = {"1234567890"};
  17. struct StringLibrary *StringBase;
  18. struct StrRequester strreq;
  19.  
  20. main()
  21. {
  22.     ULONG    ret;
  23.     long    ret2;
  24.     BPTR    Bptr;
  25.     char    buffer[80],
  26.         centerstr[80],
  27.         *prompt = "Enter a string";
  28.  
  29.     Bptr = (BPTR)(&Bstr[0]) >> 2;
  30.     buffer[0] = '\0';
  31. /* open stringlib.library */
  32.     StringBase = (struct StringLibrary *)OpenLibrary("string.library",0L);
  33.     if(StringBase == NULL) {
  34.        printf("Can't open string.library\n");
  35.        exit(0);
  36.     };
  37.  
  38.  
  39.     LtoX((ULONG)19114957, &buffer[0]);
  40.     printf("LtoX(19114957)=%s\n\n",&buffer[0]);
  41.  
  42.     ret = XtoL(&buffer[0]);
  43.     printf("XtoL(%s)=%ld\n\n", &buffer[0], ret);
  44.  
  45.     strreq.sr_LeftEdge    = (WORD)200;
  46.     strreq.sr_TopEdge     = (WORD)40;
  47.     strreq.sr_MaxOutWidth = 30L;
  48.     strreq.sr_Prompt      = prompt;
  49.     strreq.sr_OutBuff     = &buffer[0];
  50.     strreq.sr_Screen      = NULL;
  51.  
  52.     buffer[0] = 0;
  53.  
  54.     printf("StrReq(&strreq) / Length = %ld : Result = ",StrReq(&strreq));
  55.     printf("%s\n\n",&buffer[0]);
  56.  
  57.     printf("Center(&buffer[0], ¢erstr[0], 50L, ' ')\n");
  58.     printf(" ....+....1....+....2....+....3....+....4....+....5\n");
  59.  
  60.     Center(&buffer[0], ¢erstr[0], 50L, ' ');
  61.     printf("|%s|\n\n", ¢erstr[0]);
  62.  
  63.     ret2 = MidStr(&TestStr[0],&buffer[0],5,5);
  64.     printf("MidStr('%s',,5,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
  65.  
  66.     ret2 = LeftStr(&TestStr[0],&buffer[0],3);
  67.     printf("LeftStr('%s',,3) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
  68.  
  69.     ret2 = RightStr(&TestStr[0],&buffer[0],5);
  70.     printf("RightStr('%s',,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
  71.  
  72.     ret2 = InsertStr(&TestStr[0],&buffer[0],"ABCD",5);
  73.     printf("InsertStr('%s',,'ABCD',5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
  74.  
  75.     ret2 = DelStr(&TestStr[0],&buffer[0],3,5);
  76.     printf("DelStr('%s',,3,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
  77.  
  78.     ret2 = BtoCStr(Bptr, &buffer[0], 20);
  79.     printf("BtoCStr(Bstr) / Length = %ld : Result = %s\n\n", ret2, &buffer[0]);
  80.  
  81.     CloseLibrary(StringBase);
  82. }
  83.