Announcement

Collapse
No announcement yet.

Help - Mapfile with Dim-ed UDT Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help - Mapfile with Dim-ed UDT Problem

    Mapfile example of my problem

    I can not read the data exchanged pass the first Index of the Arrayed UDT

    As can be seen by the code execution the aZooKeeper() array of ZooType has the data
    but the Mapfile only delivers data from Zoo Index 1


    Example of the problem is demo-ed in the code below

    Thank you for any help

    Code:
    '
    '   Mapfile example of my problem
    '
    '   I can not read the data exchanged pass the first Index of the Arrayed UDT
    '
    '   As can be seen by the code execution the aZooKeeper() array of ZooType has the data
    '   but the Mapfile only delivers data from Zoo Index 1
    '
    '
    '   Change the %Send=-1 to compile the send file
    '              %Recv=-1 to compile the Recv file
    '
    '           Please don't do both I'm not check for that right now
    '
    '       The code is set for %Send=-1 now
    '
    '   ********************************************************************
    '
    '    The Send will add a new zoo entry on each [return]
    '
    '    5 (Index2 1-5) for Index=1 for Boston
    '    5 (Index2 1-5) for Index=2 For Omaha
    '
    '    You can see the entry value after each action
    '
    '    It will then enter "Zoo Index and Animal Index " Cycle so you can see the results that the Recv side should display
    '
    '    Entering a 0 or CR will terminate the either program at this stage
    '
    '    The Recv program goes directly into the "Zoo Index ..." section
    '
    '    If you enter the Zoo Index and Animal Index as the sender shows you SHOULD get the smae display.......
    '
    '    Well, there lays the problem.
    '
    '    The recv program can only access Zoo index 1 and it's Animal Indexs 1-5
    '
    '    NO part of Zoo index 2 is available!
    '
    '    I don't know why.
    '
    '    If you can help I thank you in advance
    '
    '
    '
    '
    '
    '   The proper code to correct this would be appreciated
    '
    '   Thank You
    '
    '
    '   Bruce Wood
    '
    
    #COMPILER PBCC 4, PBCC 5    ' I think it will work with PBCC 5
    
    %Send=-1
    %Recv=0             ' Set to -1 to Select the proper file generation
    
    #IF %Send
    #COMPILE EXE "MapFile Send"
    #ELSE
    #COMPILE EXE "MapFile Recv"
    #ENDIF
    
    #DIM ALL
    #CONSOLE ON
    
    #INCLUDE "Win32api.inc"
    
    $MapFileName="SimpleZooMap"                   ' Simple ha I thought so
    
    %MaxZoos=50     ' Max Zoos
    %MaxUnits=50
    %MaxZooNameLen=50
    %MaxAnimalNameLen=10
    %MaxBuildingNameLen=36
    %MaxBuildingUnitIDLen=36
    %MaxCageIDLen=36
    
    TYPE ZooType WORD
    uZooName                     AS  ASCIIZ * %MaxZooNameLen
    uAnimalName(%MaxUnits)       AS  ASCIIZ * %MaxAnimalNameLen
    uAnimalID(%MaxUnits)         AS  LONG
    uBuildingName(%MaxUnits)     AS  ASCIIZ * %MaxBuildingNameLen
    uBuildUnitID(%MaxUnits)      AS  ASCIIZ * %MaxBuildingUnitIDLen
    uCageID(%MaxUnits)           AS  LONG
    END TYPE
    
    %ZooTypeSize=4640             ' I know it's a static... but the Dim AT demands a Constant
    
    ' ****************************************************************************************
    
    FUNCTION PBMAIN () AS LONG
    
        LOCAL RetError,Results,a AS STRING
        LOCAL Index,Index2 AS LONG
    
         DIM MapFileHandle    AS GLOBAL LONG
         DIM MkMapViewAddress AS ZooType PTR
    
    '    LOCAL Junk AS LONG
    
        DIM MapSize AS GLOBAL LONG
    
        ' yes I want the Array to be Base 1
    
        DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType
    
        ' ***********************************
    
    '    Junk=SIZEOF(ZooType)
        MapSize=SIZEOF(ZooType)*%MaxZoos                            ' Size of the memory map request Sizeof the Type * %MaxZoos aZooKeeper has a count of Test count of 50...
    
        ' Make Mapfile
    
        CALL MakeMapFile TO MkMapViewAddress
        IF ISTRUE MkMapViewAddress THEN
            aZooKeeper(1)[email protected]     ' We have our View Address
        ELSE
            PRINT "Error on create or view map"
        END IF
    
        ' Lets test the Zoo additions
    
    #IF %Send
    
        ' Index 1 Series
    
        RetError=AssociateZoo("Boston","Cat",1,"BigCats",1)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
    
        RetError=AssociateZoo("Boston","Dog",1,"BigDogs",2)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
    
        RetError=AssociateZoo("Boston","Fish",1,"SmallFish",3)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Boston","Bird",1,"BirdHouse",4)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Boston","Buffalo",1,"Grazers",5)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        ' This will make Incr Index to 2  .. It's a Different Zoo
    
        RetError=AssociateZoo("Omaha","Elephant",1,"MegaFona",1)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Omaha","Monkey",1,"Monkey",2)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Omaha","Ape",1,"Primate",3)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Omaha","Falcon",1,"Birds of Prey",4)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        RetError=AssociateZoo("Omaha","Kangaroo",1,"Marsupial",5)
        IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
        
        ' Now give the changes to the common map file
    
        @MkMapViewAddress=aZooKeeper(1)   ' try this
    
        CALL CloseView(MkMapViewAddress)                                ' I believe I need to close the View before the other party can read the file
    
    #ENDIF
    
        PRINT
    
        Index=1
    
        DO UNTIL Index=0
    
            INPUT "Zoo Index and Animal Index " Index,Index2
    
            IF Index <=0 OR Index > %MaxZoos OR Index2 <=0 OR Index2 > %MaxUnits THEN ITERATE DO
    
            RetError=GetAssociateInfo(Index,Index2)
    
        LOOP
    
    #IF %RECV
        CALL CloseView(MkMapViewAddress)                                ' I believe I need to close the View before the other party can read the file
    #ENDIF
    
        CALL CloseMap(MapFileHandle)
    
    END FUNCTION
    
    ' ********************************************************************
    SUB PrintError ALIAS "PrintError"(BYVAL ErrorMsg AS STRING)
    
        PRINT "AssociateZoo reported this error " & ErrorMSG
    
    END SUB
    
    ' ********************************************************************
    
    FUNCTION AssociateZoo ALIAS "AssociateZoo"(pZoo AS ASCIIZ,pAnimalName AS ASCIIZ,BYVAL pAnimalID AS LONG,pBuildingName AS ASCIIZ,BYVAL pCageID AS LONG) EXPORT AS STRING
    
        LOCAL Index,Index2 AS LONG
        LOCAL Length AS LONG
    
        LOCAL Results   AS STRING
    
        REDIM atZoo(1 TO %MaxZoos) AS STRING * %ZooTypeSize AT VARPTR(aZooKeeper(1))
    
        ARRAY SCAN atZoo(), COLLATE UCASE, FROM 1 TO LEN(pZoo), = UCASE$(pZoo), TO Index
        IF ISFALSE Index THEN
            ARRAY SCAN atZoo(), FROM 1 TO 1, = $NUL, TO Index
            IF ISTRUE Index THEN
                aZooKeeper(Index).uZooName=pZoo
            ELSE
                FUNCTION="~Zoo Storage is full" : EXIT FUNCTION
            END IF
        END IF
    
        ' We have the Zoo storage index
    
        REDIM atAnimalName(1 TO %MaxZoos) AS STRING * %MaxAnimalNameLen AT VARPTR(aZooKeeper(Index).uAnimalName(1))
    
        ARRAY SCAN atAnimalName(), COLLATE UCASE, FROM 1 TO LEN(pAnimalName), = UCASE$(pAnimalName), TO Index2
        IF ISFALSE Index2 THEN
            ARRAY SCAN atAnimalName(),FROM 1 TO 1, = $NUL, TO Index2
            IF ISTRUE Index2 THEN
                aZooKeeper(Index).uAnimalName(Index2)=pAnimalName
            ELSE
                FUNCTION="~ " & pZoo & " has the maximum animals associated with it" : EXIT FUNCTION
            END IF
        END IF
    
        ERASE atAnimalName(),atZoo()
    
        ' ok push the other item into place
    
        aZooKeeper(Index).uAnimalID(Index2)=pAnimalID
        aZooKeeper(Index).uBuildingName(Index2)=pBuildingName
        aZooKeeper(Index).uCageID(Index2)=pCageID
    
        Results=FORMAT$(Index) & "," & FORMAT$(Index2)
    
        PRINT : PRINT "Zoo Name " aZooKeeper(Index).uZooName
        ?     "Animal Name "  aZooKeeper(Index).uAnimalName(Index2)
        ?     "Animal ID " aZooKeeper(Index).uAnimalID(Index2)
        ?     "Building Name "  aZooKeeper(Index).uBuildingName(Index2)
        ?     "Cage ID " aZooKeeper(Index).uCageID(Index2)
        ?     "Zoo Index "  Index
        ?     "Animal Index " Index2
        ?     "Results returned " Results
    
        PRINT
    
        WAITKEY$
    
        FUNCTION=Results
    
    END FUNCTION
    
    '   ****************************************************************
    
    FUNCTION GetAssociateInfo ALIAS "GetAssociateInfo"(BYVAL Index AS LONG,BYVAL Index2 AS LONG) EXPORT AS STRING
    
        LOCAL Results AS STRING
    
        PRINT : PRINT "Zoo Name " aZooKeeper(Index).uZooName
        ?     "Animal Name "  aZooKeeper(Index).uAnimalName(Index2)
        ?     "Animal ID " aZooKeeper(Index).uAnimalID(Index2)
        ?     "Building Name "  aZooKeeper(Index).uBuildingName(Index2)
        ?     "Cage ID " aZooKeeper(Index).uCageID(Index2)
        ?     "Zoo Index "  Index
        ?     "Animal Index " Index2
    
        PRINT
    
        FUNCTION=""
    
    END FUNCTION
    
    ' ****************************************************************************************
    
    FUNCTION MakeMapFile ALIAS "MakeMapFile" EXPORT AS LONG
    
            LOCAL MkMapViewAddress AS LONG
    
            MapFileHandle = CreateFileMapping(BYVAL -1, BYVAL 0, BYVAL %PAGE_READWRITE, BYVAL 0, MapSize, $MapFileName)
            IF ISTRUE MapFileHandle OR ( MapFileHandle = 0 AND GetLastError = %ERROR_ALREADY_EXISTS ) THEN
                MkMapViewAddress = MapViewOfFile(MapFileHandle, %FILE_MAP_ALL_ACCESS, 0, 0, 0)
                FUNCTION=MkMapViewAddress
            ELSE
                FUNCTION=%False                         ' Flag create mapping file error
            END IF
    END FUNCTION
    
    ' ****************************************************************************************
    
    FUNCTION MakeView ALIAS "MakeView" EXPORT AS LONG
    
         LOCAL MkMapViewAddress AS LONG
    
        MkMapViewAddress = MapViewOfFile(MapFileHandle, %FILE_MAP_ALL_ACCESS, 0, 0, 0)
    
        FUNCTION=MkMapViewAddress
    
    END FUNCTION
    
    SUB CloseView ALIAS "CloseView" (BYVAL ViewAddress AS LONG) EXPORT
    
        UnmapViewofFile BYVAL ViewAddress
    
    END SUB
    
    ' ****************************************************************************************
    
    SUB CloseMap ALIAS "CloseMap" (BYVAL MapHandle AS LONG) EXPORT
    
        IF ISTRUE MapFileHandle THEN CloseHandle MapFileHandle
    
    END SUB

    Bruce

  • #2
    Just a quick look at your code, you have not declared your globals before DIMming.
    As the help file shows:
    Code:
    #COMPILE EXE
    
    GLOBAL Caption AS ASCIIZ * 255
    
     
    
    FUNCTION PBMAIN() AS LONG
    
      DIM Msg AS ASCIIZ * 255
    
      CALL SetVars
    
      IF Caption = "GLOBAL test" then Msg = "Success!"
    
    END FUNCTION
    
     
    
    SUB SetVars()
    
      Caption = "GLOBAL test"
    
    END SUB
    Rod
    In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

    Comment


    • #3
      Rodney

      If you run example code, you will see that an outside global definition has no effect.

      But I normally do provide these def's.

      I put this example together to provide code in demonstrating the Mapfile exchange problem.

      Thank you for looking.

      Bruce

      Comment


      • #4
        After changing these two lines from this:
        Code:
         ARRAY SCAN atZoo(), COLLATE UCASE, FROM 1 TO LEN(pZoo), = UCASE$(pZoo), TO Index
        ARRAY SCAN atAnimalName(), COLLATE UCASE, FROM 1 TO LEN(pAnimalName), = UCASE$(pAnimalName), TO Index2
        to this:

        Code:
        ARRAY SCAN atZoo(), FROM 1 TO LEN(pZoo), COLLATE UCASE,=UCASE$(pZoo),  TO Index 
        ARRAY SCAN atAnimalName(), FROM 1 TO LEN(pAnimalName), COLLATE UCASE, = UCASE$(pAnimalName), TO Index2
        I started getting some different reponses. But there are still some things that aren't right I think, but you would know better than I.
        I would have thought that you would get a syntax error.
        Rod
        In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

        Comment


        • #5
          >I would have thought that you would get a syntax error

          #DIM ALL is your friend and will give you that undefined variable error.

          I still think this should have been the default, requiring the programmer to explicitly code...
          Code:
          #DIM NONE  '  I want to suffer.
          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Rodney:

            COLLATE UCASE position change

            No effect

            Michael:

            Under PBCC 5

            #Dim ALL
            #Dim None

            The compiler returns no errors either way

            Here is the code reformated

            So both PBCC 4 and 5 will accept it.

            Globals predefined

            No forward references

            Code:
            '
            '   Mapfile example of my problem
            '
            '   I can not read the data exchanged pass the first Index of the Arrayed UDT
            '
            '   As can be seen by the code execution the aZooKeeper() array of ZooType has the data
            '   but the Mapfile only delivers data from Zoo Index 1
            '
            '
            '   Change the %Send=-1 to compile the send file
            '              %Recv=-1 to compile the Recv file
            '
            '           Please don't do both I'm not check for that right now
            '
            '       The code is set for %Send=-1 now
            '
            '   ********************************************************************
            '
            '    The Send will add a new zoo entry on each [return]
            '
            '    5 (Index2 1-5) for Index=1 for Boston
            '    5 (Index2 1-5) for Index=2 For Omaha
            '
            '    You can see the entry value after each action
            '
            '    It will then enter "Zoo Index and Animal Index " Cycle so you can see the results that the Recv side should display
            '
            '    Entering a 0 or CR will terminate the either program at this stage
            '
            '    The Recv program goes directly into the "Zoo Index ..." section
            '
            '    If you enter the Zoo Index and Animal Index as the sender shows you SHOULD get the smae display.......
            '
            '    Well, there lays the problem.
            '
            '    The recv program can only access Zoo index 1 and it's Animal Indexs 1-5
            '
            '    NO part of Zoo index 2 is available!
            '
            '    I don't know why.
            '
            '    If you can help I thank you in advance
            '
            '
            '
            '
            '
            '   The proper code to correct this would be appreciated
            '
            '   Thank You
            '
            '
            '   Bruce Wood
            '
            
            #COMPILER PBCC 4, PBCC 5    ' I think it will work with PBCC 5
            
            %Send=-1
            %Recv=0             ' Set to -1 to Select the proper file generation
            
            #IF %Send
            #COMPILE EXE "MapFile Send"
            #ELSE
            #COMPILE EXE "MapFile Recv"
            #ENDIF
            
            #DIM ALL
            #CONSOLE ON
            
            #INCLUDE "Win32api.inc"
            
            $MapFileName="SimpleZooMap"                   ' Simple ha I thought so
            
            %MaxZoos=50     ' Max Zoos
            %MaxUnits=50
            %MaxZooNameLen=50
            %MaxAnimalNameLen=10
            %MaxBuildingNameLen=36
            %MaxBuildingUnitIDLen=36
            %MaxCageIDLen=36
            
            TYPE ZooType WORD
            uZooName                     AS  ASCIIZ * %MaxZooNameLen
            uAnimalName(%MaxUnits)       AS  ASCIIZ * %MaxAnimalNameLen
            uAnimalID(%MaxUnits)         AS  LONG
            uBuildingName(%MaxUnits)     AS  ASCIIZ * %MaxBuildingNameLen
            uBuildUnitID(%MaxUnits)      AS  ASCIIZ * %MaxBuildingUnitIDLen
            uCageID(%MaxUnits)           AS  LONG
            END TYPE
            
            %ZooTypeSize=4640             ' I know it's a static... but the Dim AT demands a Constant
            
            GLOBAL aZooKeeper() AS ZooType
            GLOBAL MapFileHandle AS LONG
            GLOBAL MapSize AS LONG
            
            ' ****************************************************************************************
            
            SUB PrintError ALIAS "PrintError"(BYVAL ErrorMsg AS STRING)
            
                PRINT "AssociateZoo reported this error " & ErrorMSG
            
            END SUB
            
            ' ********************************************************************
            
            FUNCTION AssociateZoo ALIAS "AssociateZoo"(pZoo AS ASCIIZ,pAnimalName AS ASCIIZ,BYVAL pAnimalID AS LONG,pBuildingName AS ASCIIZ,BYVAL pCageID AS LONG) EXPORT AS STRING
            
                LOCAL Index,Index2 AS LONG
                LOCAL Length AS LONG
            
                LOCAL Results   AS STRING
            
                DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType
            
                REDIM atZoo(1 TO %MaxZoos) AS STRING * %ZooTypeSize AT VARPTR(aZooKeeper(1))
            
                ARRAY SCAN atZoo(), FROM 1 TO LEN(pZoo), COLLATE UCASE, = UCASE$(pZoo), TO Index
                IF ISFALSE Index THEN
                    ARRAY SCAN atZoo(), FROM 1 TO 1, = $NUL, TO Index
                    IF ISTRUE Index THEN
                        aZooKeeper(Index).uZooName=pZoo
                    ELSE
                        FUNCTION="~Zoo Storage is full" : EXIT FUNCTION
                    END IF
                END IF
            
                ' We have the Zoo storage index
            
                REDIM atAnimalName(1 TO %MaxZoos) AS STRING * %MaxAnimalNameLen AT VARPTR(aZooKeeper(Index).uAnimalName(1))
            
                ARRAY SCAN atAnimalName(), FROM 1 TO LEN(pAnimalName),COLLATE UCASE, = UCASE$(pAnimalName), TO Index2
                IF ISFALSE Index2 THEN
                    ARRAY SCAN atAnimalName(),FROM 1 TO 1, = $NUL, TO Index2
                    IF ISTRUE Index2 THEN
                        aZooKeeper(Index).uAnimalName(Index2)=pAnimalName
                    ELSE
                        FUNCTION="~ " & pZoo & " has the maximum animals associated with it" : EXIT FUNCTION
                    END IF
                END IF
            
                ERASE atAnimalName(),atZoo()
            
                ' ok push the other item into place
            
                aZooKeeper(Index).uAnimalID(Index2)=pAnimalID
                aZooKeeper(Index).uBuildingName(Index2)=pBuildingName
                aZooKeeper(Index).uCageID(Index2)=pCageID
            
                Results=FORMAT$(Index) & "," & FORMAT$(Index2)
            
                PRINT : PRINT "Zoo Name " aZooKeeper(Index).uZooName
                ?     "Animal Name "  aZooKeeper(Index).uAnimalName(Index2)
                ?     "Animal ID " aZooKeeper(Index).uAnimalID(Index2)
                ?     "Building Name "  aZooKeeper(Index).uBuildingName(Index2)
                ?     "Cage ID " aZooKeeper(Index).uCageID(Index2)
                ?     "Zoo Index "  Index
                ?     "Animal Index " Index2
                ?     "Results returned " Results
            
                PRINT
            
                WAITKEY$
            
                FUNCTION=Results
            
            END FUNCTION
            
            '   ****************************************************************
            
            FUNCTION GetAssociateInfo ALIAS "GetAssociateInfo"(BYVAL Index AS LONG,BYVAL Index2 AS LONG) EXPORT AS STRING
            
                LOCAL Results AS STRING
            
                DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType
            
                PRINT : PRINT "Zoo Name " aZooKeeper(Index).uZooName
                ?     "Animal Name "  aZooKeeper(Index).uAnimalName(Index2)
                ?     "Animal ID " aZooKeeper(Index).uAnimalID(Index2)
                ?     "Building Name "  aZooKeeper(Index).uBuildingName(Index2)
                ?     "Cage ID " aZooKeeper(Index).uCageID(Index2)
                ?     "Zoo Index "  Index
                ?     "Animal Index " Index2
            
                PRINT
            
                FUNCTION=""
            
            END FUNCTION
            
            ' ****************************************************************************************
            
            FUNCTION MakeMapFile ALIAS "MakeMapFile" EXPORT AS LONG
            
                    LOCAL MkMapViewAddress AS LONG
            
                    MapFileHandle = CreateFileMapping(BYVAL -1, BYVAL 0, BYVAL %PAGE_READWRITE, BYVAL 0, MapSize, $MapFileName)
                    IF ISTRUE MapFileHandle OR ( MapFileHandle = 0 AND GetLastError = %ERROR_ALREADY_EXISTS ) THEN
                        MkMapViewAddress = MapViewOfFile(MapFileHandle, %FILE_MAP_ALL_ACCESS, 0, 0, 0)
                        FUNCTION=MkMapViewAddress
                    ELSE
                        FUNCTION=%False                         ' Flag create mapping file error
                    END IF
            END FUNCTION
            
            ' ****************************************************************************************
            
            FUNCTION MakeView ALIAS "MakeView" EXPORT AS LONG
            
                 LOCAL MkMapViewAddress AS LONG
            
                MkMapViewAddress = MapViewOfFile(MapFileHandle, %FILE_MAP_ALL_ACCESS, 0, 0, 0)
            
                FUNCTION=MkMapViewAddress
            
            END FUNCTION
            
            SUB CloseView ALIAS "CloseView" (BYVAL ViewAddress AS LONG) EXPORT
            
                UnmapViewofFile BYVAL ViewAddress
            
            END SUB
            
            ' ****************************************************************************************
            
            SUB CloseMap ALIAS "CloseMap" (BYVAL MapHandle AS LONG) EXPORT
            
                IF ISTRUE MapFileHandle THEN CloseHandle MapFileHandle
            
            END SUB
            
            ' *************************************************************************************
            
            FUNCTION PBMAIN () AS LONG
            
                LOCAL RetError,Results,a AS STRING
                LOCAL Index,Index2 AS LONG
            
                 DIM MapFileHandle    AS GLOBAL LONG
                 DIM MkMapViewAddress AS ZooType PTR
            
            '    LOCAL Junk AS LONG
            
                DIM MapSize AS GLOBAL LONG
            
                ' yes I want the Array to be Base 1
            
                DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType
            
                ' ***********************************
            
            '    Junk=SIZEOF(ZooType)
                MapSize=SIZEOF(ZooType)*%MaxZoos                            ' Size of the memory map request Sizeof the Type * %MaxZoos aZooKeeper has a count of Test count of 50...
            
                ' Make Mapfile
            
                CALL MakeMapFile TO MkMapViewAddress
                IF ISTRUE MkMapViewAddress THEN
                    aZooKeeper(1)[email protected]     ' We have our View Address
                ELSE
                    PRINT "Error on create or view map"
                END IF
            
                ' Lets test the Zoo additions
            
            #IF %Send
            
                ' Index 1 Series
            
                RetError=AssociateZoo("Boston","Cat",1,"BigCats",1)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Boston","Dog",1,"BigDogs",2)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Boston","Fish",1,"SmallFish",3)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Boston","Bird",1,"BirdHouse",4)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Boston","Buffalo",1,"Grazers",5)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                ' This will make Incr Index to 2  .. It's a Different Zoo
            
                RetError=AssociateZoo("Omaha","Elephant",1,"MegaFona",1)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Omaha","Monkey",1,"Monkey",2)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Omaha","Ape",1,"Primate",3)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Omaha","Falcon",1,"Birds of Prey",4)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                RetError=AssociateZoo("Omaha","Kangaroo",1,"Marsupial",5)
                IF LEFT$(RetError,1)="~" THEN CALL PrintError(RetError) : EXIT FUNCTION
            
                ' Now give the changes to the common map file
            
                @MkMapViewAddress=aZooKeeper(1)   ' try this
            
                CALL CloseView(MkMapViewAddress)                                ' I believe I need to close the View before the other party can read the file
            
            #ENDIF
            
                PRINT
            
                Index=1
            
                DO UNTIL Index=0
            
                    INPUT "Zoo Index and Animal Index " Index,Index2
            
                    IF Index <=0 OR Index > %MaxZoos OR Index2 <=0 OR Index2 > %MaxUnits THEN ITERATE DO
            
                    RetError=GetAssociateInfo(Index,Index2)
            
                LOOP
            
            #IF %RECV
                CALL CloseView(MkMapViewAddress)                                ' I believe I need to close the View before the other party can read the file
            #ENDIF
            
                CALL CloseMap(MapFileHandle)
            
            END FUNCTION

            *****

            The problem still remains

            DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType

            Code snippet

            ' I get MapviewAddess

            'Assign aZooKeeper(1) this address

            aZooKeeper(1)[email protected] ' We have our View Address

            ' Before the MKMapViewAddress Close
            ' I do a transfer back

            @MkMapViewAddress=aZooKeeper(1)

            Is this an incorrect method of doing the transfer back?

            It certainly seems so as the receiver gets valid information from only one aZooKeeper array element -> aZooKeeper(x) x=1


            Within the sender program the data is perfectly retrievable from all aZooKeer(x) elements that received data (empty for those that are blank)

            In code example:

            The recv gets the aZooKeeper(1) block correct

            but sadly the aZooKeeper(2) block is at default values.

            I'm missing a key critical code component!

            This darn problem is stressing me out. It's stopping the code completion.

            Thank you all

            If you can correct the problem I would be grateful.

            Bruce

            Comment


            • #7
              I think I have it!!!

              Use DIM aZooKeeper(1 TO %MaxZoos) AS GLOBAL ZooType AT MkMapViewAddress

              This allows a direct write into the mapfile address space.

              Thank you for your help

              This site and PowerBasic is incredible.

              Bruce

              Comment

              Working...
              X