Author Topic: Copy and Paste from other Sources  (Read 2078 times)

MalcomR

  • Newbie
  • *
  • Posts: 44
Copy and Paste from other Sources
« on: March 30, 2023, 08:41:26 PM »
Is there any way to paste text from another text editor into a VA command?  VA's text editing does not allow for things like find/replace or other useful commands.  I can select all, paste into a text editor and use it's features but there does not seem to be a way to get the changed text back into the VA command editor window.  Maybe I've missed the function but I can't seem to find anything to do this with.

Thanks.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Copy and Paste from other Sources
« Reply #1 on: March 30, 2023, 10:44:57 PM »
Unfortunately, no.  VoiceAttack's interface is not a text-based IDE, so there is no way to paste actions into commands.  The ability to copy text out of VA is to make it easy to convey to other users what your actions are doing- to share and for support.

The latest betas of VA have a 'find' feature as well as a 'command snippet' feature, but no way to replace actions/groups of actions.

Sorry about that! 

MalcomR

  • Newbie
  • *
  • Posts: 44
Re: Copy and Paste from other Sources
« Reply #2 on: March 30, 2023, 11:02:35 PM »
Okay.  Thanks.  A find feature will help some.

I was thinking of being able to replace strings, not groups of actions but say change XYZ to ABC in actions.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Copy and Paste from other Sources
« Reply #3 on: March 31, 2023, 08:51:38 AM »
There is a workaround to doing just that -   If you export your profile (.vap) as XML, you can do a find/replace (carefuly) within the file using Notepad.  Then, save the file and re-import the .vap as a new profile.

If you find that you'll be doing this again and again for the same text later on, you'll want to consider using variables and tokens (won't go into all that here ;))

Hope that helps!

MalcomR

  • Newbie
  • *
  • Posts: 44
Re: Copy and Paste from other Sources
« Reply #4 on: March 31, 2023, 09:00:27 AM »
So I export as a XML, edit, save. Then how do I get it back to a vap?

I do make extensive use of variables and tokens as I like to have definitions in one place so I change it there and the rest of the profile or command sees the new value.  I find a search and replace handy when I'm going back and updating older profiles.

I'll check out the export just so I'm familiar with it.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Copy and Paste from other Sources
« Reply #5 on: March 31, 2023, 09:28:37 AM »
XML .vap files can be imported directly (assuming they're still formatted correctly).

All .vap files used to be XML-formatted (and thus importing is still backwards-compatible with them); the current binary standard was introduced later on, mainly to allow for smaller file sizes.

MalcomR

  • Newbie
  • *
  • Posts: 44
Re: Copy and Paste from other Sources
« Reply #6 on: March 31, 2023, 09:32:12 AM »
Okay.  I didn't realize that.

pilbrob

  • Newbie
  • *
  • Posts: 1
Re: Copy and Paste from other Sources
« Reply #7 on: April 03, 2023, 06:27:07 AM »
Gary - brilliant piece of software. I'd love a search and replace function btw, it would save me rather a lot of time. Not expecting it, though!

Pfeil - MVP :)

I just signed up for the forum so I could ask pretty much this question.

I'd already worked out that you could export as an xml file and search and replace in that.

Couple of queries:

1. When I re-import the xml, it seems to be back in binary form when I export it again. That's good! What I'm wondering is whether there is any downside of exporting as xml and reimporting in terms of file sizes and performance? Does it just get immediately turned back into a binary of the same size that you started with when you reimport the xml file?

2. Is it better to use Notepad++ to edit the xml? I know that standard notepad can damage certain types of files (from modding other software), Notepad++ seems to be less destructive?

3. Is there any chance of damaging the profile if I am repeatedly exporting as xml and reimporting after a search and replace? I won't be changing formatting, I'm just doing a simple search and replace for folder paths. But I'll probably do the export -> import a hundred times. Just checking that I'm not going to corrupt anything, I've been working on the profile for a good few years now and don't want to break it!

4. The reason I'm wanting to do search and replace is to change folder paths.

For example, if I have a command that plays a file from {VA_SOUNDS}\ATP_Pack\0 FO Responses\Cessna152\CL2\4, I want to be able to duplicate that command and change the path to {VA_SOUNDS}\ATP_Pack\0 FO Responses\Boeing737NG\CL2\4

It there any way to do that apart from the export .xml -> search and replace -> import profile routine that we're talking about here?

Cheers guys, and thanks again for building such a great piece of software and all of the support that we find here on the forum. :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Copy and Paste from other Sources
« Reply #8 on: April 03, 2023, 10:42:38 AM »
1. When I re-import the xml, it seems to be back in binary form when I export it again. That's good! What I'm wondering is whether there is any downside of exporting as xml and reimporting in terms of file sizes and performance? Does it just get immediately turned back into a binary of the same size that you started with when you reimport the xml file?
.vap files aren't used by VoiceAttack internally; they essentially contain information on what values should be used when creating profile and command information within the profile database, so when importing, VoiceAttack is internally creating data structures, and then filling them in with the information provided in the .vap file.

So regardless of whether you're using a binary format .vap, or an XML-formatted .vap, the structure in the database is the same. Only the values are provided by the .vap file.

In other words, as long as the values in the .vap file are identical, performance and size within the profile database should also be identical, and identical to manually inputting the same values through the GUI.


2. Is it better to use Notepad++ to edit the xml? I know that standard notepad can damage certain types of files (from modding other software), Notepad++ seems to be less destructive?
Notepad should be fairly safe in this context (you definitely wouldn't want to use WordPad though).

Notepad++ could make it easier to spot certain mistakes because of syntax and matching tag highlighting though, if you were to manually alter values/formatting.


3. Is there any chance of damaging the profile if I am repeatedly exporting as xml and reimporting after a search and replace? I won't be changing formatting, I'm just doing a simple search and replace for folder paths. But I'll probably do the export -> import a hundred times. Just checking that I'm not going to corrupt anything, I've been working on the profile for a good few years now and don't want to break it!
Technically, any time a file is being written to there is a theoretical possibility that something goes wrong (this is certainly not specific to VoiceAttack, either), but that's in the same vein as the possibility of having an accident every time you drive a car.

It's good to take precautions (making backups of your .vap file/wearing a seatbelt and driving defensively), but it's not nearly likely enough to avoid doing it.


4. The reason I'm wanting to do search and replace is to change folder paths.

For example, if I have a command that plays a file from {VA_SOUNDS}\ATP_Pack\0 FO Responses\Cessna152\CL2\4, I want to be able to duplicate that command and change the path to {VA_SOUNDS}\ATP_Pack\0 FO Responses\Boeing737NG\CL2\4

It there any way to do that apart from the export .xml -> search and replace -> import profile routine that we're talking about here?
Aside from changing each individual command/action manually through the GUI, no.


If you're using identical commands in multiple contexts, you could consider using a token to alter the path dynamically, E.G.
Code: [Select]
{VA_SOUNDS}\ATP_Pack\0 FO Responses\{TXT:aircraft}\CL2\4assuming the folder structure otherwise matches, as it does in your examples.

You'd then set the value of that text variable, "aircraft", to "Cessna152" or "Boeing737NG" to use the relevant file.