PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Wed Aug 03, 2011 8:52 am Post subject: |
|
|
The following program illustrates the fact that you can have shared memory between two instances of the same executable.
First make sure that the file stat.dat is erased and then run the executable in one DOS box. Now run the same exe in a another DOS box.
| Code: |
include <windows.ins>
character,pointer::msg*80
logical fexists@
integer ercode
allocate(msg, SHARENAME="MyMemory")
if(.NOT. fexists@("stat.dat",ercode)) then
OPEN(10,FILE="stat.dat")
CLOSE(10)
print*, "Type a message to send. Do not use spaces..."
read*, msg
call SIGNAL_SEMAPHORE@("MySemaphore")
deallocate(msg)
else
print*, "Waiting for message..."
call WAIT_ON_SEMAPHORE@("MySemaphore")
print*, msg(1:len_trim(msg))
endif
end
|
|
|