Simple Login/Logout Example using Basic Script

'specify name of project being addressed

Const proj As String = "onepoint"

'user configured in that project

const cimpuser as string = "testuser"

'password for that configured user

const cimpuserpw as string = "testpassword"

'point that will have a value configured within the previously specified project

const pointwithvalue as string ="pointwithvalue"

Sub gp

    trace "point value = " & pointget("\\" & proj & "\" & pointwithvalue)

end sub

sub nouser

    Call CimClearProjectUserPassword(cimpuser, cimpuserpw, proj)

end sub

sub testuser

    Call CimSetProjectUserPassword(cimpuser, cimpuserpw, proj)

end sub

sub main

'Run this program immediately after starting the project, stepping

'through line by line -

    call testuser ' specify configured user for login

    call gp

    call nouser ' clear "auto login" user

    Call CimLogout(proj) 'logout from last user

    Call CimLogin(proj) 'initiate a login sequence - GUI should be invoked

    'need to wait for previous login process to be completed before continuing

    'on or fetch of data may fail with error indicating user not logged in...

    call gp 'access data

    Call CimLogout(proj)

end sub

More information

Login/Logout API support.