Ruby/DL - assigning to global variables?

Discussion in 'Ruby' started by ajwitte@gmail.com, Apr 7, 2005.

  1. Guest

    Hi,

    I know I can do:

    module Foo
    extend DL::Importable
    dlload 'libquux.so'
    @@bar = symbol 'bar'
    end

    where 'bar' is a variable in libquux. How do I assign a value to bar?

    Specifically, I am trying to use libreadline via Ruby/DL (yes, I know
    about ext/readline) and am trying to assign a callback to
    rl_attempted_completion_function.

    Thanks,

    /Andrew
    , Apr 7, 2005
    #1
    1. Advertising

  2. wrote:
    > module Foo
    > extend DL::Importable
    > dlload 'libquux.so'
    > @@bar = symbol 'bar'
    > end
    >
    > where 'bar' is a variable in libquux. How do I assign a value to bar?


    @@bar is considered as a pointer to a value. If its type is int, you can assign
    an integer value as follows.

    IntValue = struct ["int value"]
    obj = IntValue.new(@@bar)
    obj.value = 1
    --
    Takaaki Tateishi <>
    Takaaki Tateishi, Apr 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    456
    Wayne
    Nov 11, 2003
  2. jubelbrus
    Replies:
    5
    Views:
    602
    JohnQ
    Jul 20, 2007
  3. mark4asp
    Replies:
    1
    Views:
    203
  4. Tony Archer

    Global Variables? Multi-Application Variables?

    Tony Archer, Nov 24, 2003, in forum: ASP General
    Replies:
    5
    Views:
    210
    Tony Archer
    Nov 25, 2003
  5. weston
    Replies:
    1
    Views:
    238
    Richard Cornford
    Sep 22, 2006
Loading...

Share This Page