Ask Your Question
0

Basic: What's the syntax for variable object names?

asked 2017-04-25 01:36:34 +0200

EasyTrieve gravatar image

updated 2017-04-25 01:40:21 +0200

For example, if I have a string variable in Basic such as something = "foo", how can I use this variable in dot notation or the like to refer to foo.value?


For example in JavaScript one can write [something].value

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-04-25 04:59:54 +0200

EasyTrieve gravatar image

updated 2017-04-25 05:02:56 +0200

I'll describe a workaround below, not the best solution.

This example is to allow a version# (iVersion) to select a specific Library Module for settings. First here is how I would like it to work. It is how JavaScript syntax works:

 sBaseModuleName = "AnnotatedBackupsSettings"  

 sPath      = [sBaseModuleName & "V" & iVersion].GETsPath()
 iMaxCopies = [sBaseModuleName & "V" & iVersion].GETiMaxCopies()

Next, here is a workaround for a limited set of variable values. Notice the ugly necessity for an overflow warning at the end.

Select Case iVersion

    Case 1
        sPath       = AnnotatedBackupsSettingsV1.GETsPath()
        iMaxCopies  = AnnotatedBackupsSettingsV1.GETiMaxCopies()

    Case 2
        sPath       = AnnotatedBackupsSettingsV2.GETsPath()
        iMaxCopies  = AnnotatedBackupsSettingsV2.GETiMaxCopies()

    Case 3
        sPath       = AnnotatedBackupsSettingsV3.GETsPath()
        iMaxCopies  = AnnotatedBackupsSettingsV3.GETiMaxCopies()

    Case Is > 3
        MsgBox("OOPS, select statement is too short for iVersion = " _
        & iVersion & "." &chr(10)&chr(10)&_
        "Increase the number of case statements to fix this.",_
        0+48,"FATAL ERROR"):stop

End Select
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-04-25 01:36:34 +0200

Seen: 46 times

Last updated: Apr 25 '17