home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12192.ZIP / Q2.BAS < prev    next >
BASIC Source File  |  1990-02-02  |  2KB  |  61 lines

  1. '===== Q2.BAS =====
  2. REM $INCLUDE: 'QUEUE.BI'
  3.  
  4. 'Functions to place and retrieve data with shared memory (UTIL.BAS)
  5. DECLARE FUNCTION STRINGPOKE%(_
  6.               P1  AS ADDRESS,_
  7.               P2  AS STRING,_
  8.               P3  AS INTEGER)
  9. DECLARE FUNCTION STRINGPEEK%(_
  10.               P1  AS ADDRESS,_
  11.               P2  AS STRING,_
  12.               P3  AS INTEGER)
  13. DEFINT A-Z
  14. DIM info AS ADDRESS
  15. DIM ep  AS STRING*1
  16.  
  17. 'Queue Name
  18. QNAME$="\QUEUES\NANCYBA"+CHR$(0)
  19.  
  20. 'Shared memory name
  21. DNAME$="\SHAREMEM\NANCYBA"+CHR$(0)
  22.  
  23. CLS
  24. 'Get the shared segment
  25. x=DosGetShrSeg%(varseg(dname$),sadd(dname$),selector)
  26. IF (x) THEN
  27.    Print "An error occurred.  The number is : ";x
  28.    stop
  29. ELSE
  30.    Print "The SEGMENT ";selector;" was CREATED"
  31. END IF
  32. 'To open Queue all that is needed is the Queue name
  33. x=DosOpenQueue%(PID,Qhandle,varseg(Qname$),sadd(Qname$))
  34. IF (x) THEN
  35.    Print "An error occurred.  The number is : ";x
  36.    STOP
  37. ELSE
  38.    Print "The QUEUE is OPENED."
  39.    Print "The HANDLE is : ";qhandle
  40. END IF
  41. FOR i = 0 to 6
  42.    info.segment=selector
  43.    info.offset=i*10
  44.    st$="ITEM"+str$(i)
  45.    strlen=len(st$)
  46.    IF (stringpoke%(info,st$,strlen)) THEN
  47.       PRINT "ERROR"
  48.    ELSE
  49.       x=DosWriteQueue%(QHandle,i+5,strlen,_
  50.                        info.segment,info.offset,0)
  51.       IF (x) THEN
  52.          Print "An error occurred.  The number is : ";x
  53.       ELSE
  54.               Print "The Item was written to the QUEUE"
  55.      END IF
  56.    END IF
  57. NEXT i
  58. Print "Enter any key to quit..."
  59. while inkey$="" :WEND
  60. END
  61.