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 >
Wrap
C/C++ Source or Header
|
1990-02-25
|
2KB
|
83 lines
/*********************************************************************
* LibTest.c
*
* Test program for string.library
*
*********************************************************************/
#include <exec/types.h>
#include <exec/libraries.h>
#include <graphics/display.h>
#include <intuition/intuition.h>
#include <libraries/stringlib.h>
char Bstr[] = { 0x12,'T','h','i','s',' ','i','s',' ','a',' ','B','s','t','r','i','n','g','.' };
char TestStr[] = {"1234567890"};
struct StringLibrary *StringBase;
struct StrRequester strreq;
main()
{
ULONG ret;
long ret2;
BPTR Bptr;
char buffer[80],
centerstr[80],
*prompt = "Enter a string";
Bptr = (BPTR)(&Bstr[0]) >> 2;
buffer[0] = '\0';
/* open stringlib.library */
StringBase = (struct StringLibrary *)OpenLibrary("string.library",0L);
if(StringBase == NULL) {
printf("Can't open string.library\n");
exit(0);
};
LtoX((ULONG)19114957, &buffer[0]);
printf("LtoX(19114957)=%s\n\n",&buffer[0]);
ret = XtoL(&buffer[0]);
printf("XtoL(%s)=%ld\n\n", &buffer[0], ret);
strreq.sr_LeftEdge = (WORD)200;
strreq.sr_TopEdge = (WORD)40;
strreq.sr_MaxOutWidth = 30L;
strreq.sr_Prompt = prompt;
strreq.sr_OutBuff = &buffer[0];
strreq.sr_Screen = NULL;
buffer[0] = 0;
printf("StrReq(&strreq) / Length = %ld : Result = ",StrReq(&strreq));
printf("%s\n\n",&buffer[0]);
printf("Center(&buffer[0], ¢erstr[0], 50L, ' ')\n");
printf(" ....+....1....+....2....+....3....+....4....+....5\n");
Center(&buffer[0], ¢erstr[0], 50L, ' ');
printf("|%s|\n\n", ¢erstr[0]);
ret2 = MidStr(&TestStr[0],&buffer[0],5,5);
printf("MidStr('%s',,5,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
ret2 = LeftStr(&TestStr[0],&buffer[0],3);
printf("LeftStr('%s',,3) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
ret2 = RightStr(&TestStr[0],&buffer[0],5);
printf("RightStr('%s',,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
ret2 = InsertStr(&TestStr[0],&buffer[0],"ABCD",5);
printf("InsertStr('%s',,'ABCD',5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
ret2 = DelStr(&TestStr[0],&buffer[0],3,5);
printf("DelStr('%s',,3,5) / Length = %ld : Result = %s\n\n", &TestStr[0], ret2, &buffer[0]);
ret2 = BtoCStr(Bptr, &buffer[0], 20);
printf("BtoCStr(Bstr) / Length = %ld : Result = %s\n\n", ret2, &buffer[0]);
CloseLibrary(StringBase);
}