Announcement

Collapse
No announcement yet.

ByCopy and Global Var's

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

    ByCopy and Global Var's

    I probably know the answer to this but lets see what others think.


    I have a global variable g_hdEncryptionKey lets say...
    It contaisn a HEX EQUIVELANT of a binary key used for en cryption, so lets say that key looked like this:


    g_hdEncryptionKey = "A1B2C3D4E5F6A1B2C3D4E5F6"


    Now, I want to keep this global variable just the way it is and then allow each function to call yet another function which will then modify the key for it's purpose.

    I don't want it modifying the Global key however because other functions need it just like it is.


    What's the "BEST" way to do this?
    It's only 16 bytes long basically, would this be ByVal or ByCopy? I want to pass a COPY of the key basically...

    Think I answered my own question but lets see...

    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    #2
    Yup, BYCOPY seems quite reasonable, provided the target sub/function is expecting a BYREF dynamic string.

    For all intents and purposes (with this type of usage), there is little difference between BYVAL/BYCOPY unless the target sub/function is expecting the string BYVAL, in which case, BYCOPY will not be the best choice.



    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


      #3
      Thanks Lance,
      I knew you had answered this question before.
      The bug actually went away after I rebooted. I beat my head against the wall for 4 hours and then said the heck with it and rebooted...

      (Well I didnt' literally beat my head against the wall


      Scott

      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎