Category : Word Processors
Archive   : HP22D5.ZIP
Filename : WITEM.C

 
Output of file : WITEM.C contained in archive : HP22D5.ZIP
#include "extern.h"

/*
** This routine searches a string of items for a particular item and returns
** its item position (or 0 it it wasn't there). For example:
**
** whichItem("orange,apple,fruit","apple") -- returns 2
**
** To call this routine from HyperPAD:
**
** put whichItem(page field 1,"fruit") into w;
**
** To use a different item delimiter, pass it as the third parameter:
**
** whichItem("orange|apple|fruit","apple","|") -- returns 2
**
*/
whichitem(NumArgs,hList,hItem,hDelimiter)

int NumArgs;
HANDLE hList,hItem,hDelimiter;

{
PTR p,item,s;
int c = 1;
int rep,rc;
char d;

if (NumArgs < 2 || NumArgs > 3) return(STOP);

/* p = pointer to item list */
p = deref(hList);

/* item = pointer to item */
item = deref(hItem);

/* d = delimiter (use a comma if delimiter is not specified) */
d = (NumArgs == 3) ? *deref(hDelimiter) : ',';

while (1) {
s = p;
while (*p && (*p != d)) p++;
if (rep = *p) *p = '\0';

rc = strcmpi(s,item);
if (rep) *p = d;
if (!rc) break;
if (rep) p++;
else {
c = 0;
break;
}
c++;
}

ReturnValue(itoh(c));

return(STOP);
}

POOL pascal Pool[] = {
{ "whichItem",
whichitem,
0,
FUNCTION},

{ NULL, /* NULLs signify the end of the table */
NULL,
0,
0} };



  3 Responses to “Category : Word Processors
Archive   : HP22D5.ZIP
Filename : WITEM.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/