Author Topic: Initialising Profile  (Read 2256 times)

HansNel

  • Guest
Initialising Profile
« on: July 06, 2018, 08:16:29 AM »
Firstly, forgive me asking so many questions. As soon as I get into this, I shall also become a Jedi Master!

1) Is there a way to initialize say "VARIABLES" whose scope is profile wide?
Say eg USERNAME = Hans    then I can use USERNAME instead of Hans in all my commands.
Basically, I need some variables set up just after the profile is loaded. Can I save these variables to disk to load it every time he profile is loaded. So is essence I would like to get a "profile" of the user so:
1) Boolean (which is set to 0 when VA profile is run the 1st time) to check is user has already entered his/her details?
If not the UserProfile command is run where important variables are loaded and saved as well.
The user can also call this UserProfile command should he/she which to change a variable value.
One (of many needed preloaded variables) example could be that VA greets the User by name upon opening the profile.

2) Can I call a "Function"...a command where NONE of the checkboxes are selected? How do I reference this function?

3) Can I call a VA Command from within another VA Command? HOW?

3) This is a big on, I guess. I know VB.NET and I JOYFULLY noticed VA supports VB.NET. Is there a document that explains a bit more of the integration between VB and VA? Eg. HOW do I call a VB.NET routine I wrote?

But, ok, points 1 to 3 are more important for now than 4.

Thank you my friends.
Hans

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Initialising Profile
« Reply #1 on: July 06, 2018, 09:58:16 AM »
Quote
1) Boolean (which is set to 0 when VA profile is run the 1st time) to check is user has already entered his/her details?
If not the UserProfile command is run where important variables are loaded and saved as well.
The user can also call this UserProfile command should he/she which to change a variable value.
One (of many needed preloaded variables) example could be that VA greets the User by name upon opening the profile.
Here is a simple example covering a few of the items you're talking about:
Code: [Select]
// Retrieve boolean variable saved to the profile
Set Boolean [>>ProfileInitialized] to [Saved Value] (save value to profile)
// Check if profile has NOT been initialized
Begin Boolean Compare : [>>ProfileInitialized] Equals False
    // Do stuff for profile initialization and save values to the profile
    Set integer [Int1] value to 5 (save value to profile)
    Set Text [Text1] to 'puppies' (save value to profile)
    Set Boolean [IsRaining] to False (save value to profile)
    // Set boolean variable to indicate profile is initialized and save to the profile
    Set Boolean [>>ProfileInitialized] to [Saved Value] (save value to profile)
    // Provide voice feedback to user
    Say, 'Profile initialization complete'
Else
    // Retrieve pre-initialized variables that are already saved to the profile
    Set integer [Int1] value to [Saved Value]
    Set Text [Text1] to [Saved Value]
    Set Boolean [IsRaining] to [Saved Value]
End Condition
Note that the ">>" before the boolean indicates that the variable is "profile-scoped." You can read more about scoped variables (which can be quite handy for variable management) in the VA manual.

Quote
2) Can I call a "Function"...a command where NONE of the checkboxes are selected? How do I reference this function?
Yes. Simply create a new command (call it whatever you like, I'll call it MyFunction) and add whatever content you want in this command. Then you can simply call for it in other commands via the VoiceAttack Action 'Execute Another Command' like this:
Code: [Select]
Execute command, 'MyFunction' (and wait until it completes)

Quote
3) Can I call a VA Command from within another VA Command? HOW?
Same answer as #2. From a naming point of view I tend to call "Commands" any VA command that can be executed with a "When I ..." and I call "Functions" VA commands that can only be activated by calling the 'Execute Another Command' action (sounds like you're implying this as well).

Quote
4) This is a big on, I guess. I know VB.NET and I JOYFULLY noticed VA supports VB.NET. Is there a document that explains a bit more of the integration between VB and VA? Eg. HOW do I call a VB.NET routine I wrote?
In the Command Edit window simply select: Other => Advanced => Execute an Inline Function => VB.net Code. The help document has some sections about using VB.net with VA (search for VAProxy for more info), but I suggest you also check out the Inline Functions section of the forum. Most of the stuff I've uploaded is in C# but you should be able to get the idea and make conversions to VB.net when needed. I try to provide comments for EVERYTHING to make it easier for others to learn. Like previously mentioned in another thread the inline functions are most effective at extending VA's functionality, but you can certainly simplify some VA operations (particularly when it comes to more complex nested conditional statements, array processing, etc.).

HansNel

  • Guest
Re: Initialising Profile
« Reply #2 on: July 06, 2018, 11:51:18 AM »
Hi Exergist! Is there a way I can call a Command/Function as a profile is loaded ie the command executes automatically as the profile is loaded and initialized? Perhaps your large code block on top covers it, but WHERE to I enter these code lines?

Thank you Exergist! Now I need time to absorb all this. I really appreciate it.

Keep well
Hans :)
« Last Edit: July 06, 2018, 12:05:19 PM by HansNel »

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Initialising Profile
« Reply #3 on: July 06, 2018, 01:00:42 PM »
You can have a VA command automatically launch when you perform certain actions. Check out the "Profile Options" menu and there should be fields for selecting commands to launch under different circumstances.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Initialising Profile
« Reply #4 on: July 06, 2018, 01:02:43 PM »
Perhaps your large code block on top covers it, but WHERE to I enter these code lines?

Most of the examples you see(with exception of those using C# or VB.net) are a representation of what the action list of your command would look like.

The examples will illustrate how your command can be made to work, however it is not possible to copy-paste that text into VoiceAttack to make a command directly.
The command can be recreated by adding the appropriate actions to your command in the given order, with the given parameters.