Discussion:
Merging two or more unique strings
(too old to reply)
MrSafe
2008-08-11 17:40:07 UTC
Permalink
Hi,Problem: I want to be able to merge two or more completely different strings into a single string. These strings can contains any letter or number; I don't want to merge the entire string all the time I want to be able to merge certain parts of it for example: String A contains: "Have A" String B contains: "Nice Day" String C contains: "#1" I want to be able to combine these strings in any form such as: "1 Have Nice A Day #".I did a quite a bit of searching on Lab view I have found "Merge Query Expressions" but I don't think it will do what I am looking for I am still trying to get an output with it but I am unable to get at currently. I don't expect anyone to give me a flat out answer but if you could point me in the right direction I would be grateful. Any example I will happily accept thank you.Message Edited by MrSafe on 08-11-2008 12:32 PMMessage Edited by MrSafe on 08-11-2008 12:32 PM
tst
2008-08-11 17:40:08 UTC
Permalink
What's the logic for the merging? Is it done automatically? Does the user decide? If so, what kind of interface would they use?
The functions in the string palette should be enough for pretty much anything you want to do, but you have to know exactly what you want first.
MrSafe
2008-08-11 18:10:06 UTC
Permalink
It will be done automatically. All the user will do is select a couple of options such as locating a file that loads a set of data. The program will then take information from the file then combine that with another set of values to make a new file based on what it is reading. I can do everything so far EXCEPT merge strings to my liking. but the process will remain the same and consistent so it can be automated.I am not sure string palette can do it I have lab view 8.2 standard edition perhaps i am simply very inexperienced with strings to realize this?
tst
2008-08-11 18:10:08 UTC
Permalink
You still haven't explained the logic of what you want to do (meaning how the program will know how to combine the strings), but you can probably do everything you want with these functions:

- Shift registers

- Concatenate Strings

- String Subset

Searching for them should provide more data.
If you want to learn more about LabVIEW, I suggest you try looking at some of <a href="http://wiki.lavag.org/LabVIEW_tutorial#External_Links" target="_blank">these tutorials</a>.
MrSafe
2008-08-11 18:10:11 UTC
Permalink
That is hard to explain for me but I will try my best: The way it will work is:1: Prompts User for a Template file2: User Selects file3: Program Grabs information from the file which is an excel file4: Information from file is converted to strings which is done automatically no prompt is given to user it is done behind the scenes.
MrSafe
2008-08-11 18:40:05 UTC
Permalink
A question that came up just a minute ago: If lets say I have a path for a file C:test\foldername\sourcefile.xlsHow do I get labview to read the path and send it back to me in a form of a string if the folder will change(meaning it will change in could be 3 characters could be 2 could be 20)?
tst
2008-08-11 19:40:05 UTC
Permalink
You still haven't explained what logic will be used to construct the string. Until you do that, we can't really help.
Your questions in general seem to indicate that you're a beginner. I would strongly suggest taking some of the tutorials I linked to earlier.
As for the folder name question, I can't say I understood it, but using Array of Strings to Path might help you.
Mythilt
2008-08-11 21:10:04 UTC
Permalink
Hmm, from what he's said so far, it sounds like the idea is along the lines of read a config file and an excel file.&nbsp; The config file will tell the program something like 'new string' = 'Cell A1' + 'Cell B3'.
From the example it also sounds like he wants to add some other abilities.
Do you know what the extent of the 'commands' you will need to use will be?
MrSafe
2008-08-11 21:40:06 UTC
Permalink
That's my problem I don't know how far into merging I will need to go..I am reading a toturial right now which a someone provided me I. I apologize for making this a puzzle for everyone I am a beginner and that's part of the problem.
MrSafe
2008-08-13 19:10:09 UTC
Permalink
I have attached 3 files&nbsp;&nbsp;1:Testonly is the main vi which calls two other files which are: (1) mergstrings (2)filepath&nbsp;All this does is combine a path with a string of yourchoice.&nbsp;You will have to enter the second set of characters inside the mergstrings.vi and also use this to use&nbsp; view the newly formed string this could have be easily changed I will update it when I have a little bit more time.


FilePath.vi:
http://forums.ni.com/ni/attachments/ni/170/349099/1/FilePath.vi


MergingStrings.vi:
http://forums.ni.com/ni/attachments/ni/170/349099/2/MergingStrings.vi


testonly.vi:
http://forums.ni.com/ni/attachments/ni/170/349099/3/testonly.vi
GerdW
2008-08-13 19:10:10 UTC
Permalink
Hi MrSafe,&nbsp;as you're a beginner: Please don't use string functions to build path!There are special functions to split/build a path and there are path constants too (like &quot;Empty path&quot;). This way you avoid hazzles with file system specific characters. And you don't need to convert an empty string to a path when there is an appropriate constant <a href="http://forums.ni.com/t5/util/emoticonspopuppage" class="emoticon-link" target="_blank"><img src="Loading Image..." border="0" alt=":smileywink:" title="Smiley Wink"></a> &nbsp;From this I would advise you to take beginners courses on LabView, <a href="http://www.ni.com/academic/lv_training/how_learn_lv.htm" target="_blank">here</a> you can find some.
MrSafe
2008-08-13 19:40:05 UTC
Permalink
Thank you I am currently reading quite a bit currently =) one thing I forgot to mention about the vi that I recently posted how come the subvi( the files inside testonly) must be open in order for them to recieve values? is there anyway to fix that?
GerdW
2008-08-13 19:40:06 UTC
Permalink
Hi MrSafe,&nbsp;what do you mean by that?The subvis will receive all values where you connected a wire to their input. Otherwise they will use the default value for that control..&nbsp;And for your second subvi you only connected one (former, see my last attachment) string input to the connector pane, the second string control isn't connected and hence will not get any new values. Message Edited by GerdW on 08-13-2008 09:14 PM
MrSafe
2008-08-13 19:40:07 UTC
Permalink
Currently the VI Testonly contains mergstrings.vi and filepath.vi&nbsp;When you excute testonly.vi it will run filepath.vi which asks the user to locate a file(could be any file for this example) and return THE exact location and file name. Which is sent to the mergstrings.vi where it is combined with a string of your choice.&nbsp;However if you excute the testonly.vi the mergstrings.vi doesn't recieve any values. However, if I open the mergstrings.vi i can see the values being recived as soon as I excute testonly.vi&nbsp;&nbsp;&nbsp;Message Edited by MrSafe on 08-13-2008 02:19 PM
GerdW
2008-08-13 19:40:07 UTC
Permalink
Hi MrSafe,&nbsp;how do you know that &quot;mergstring&quot; doesn't receive any values when you don't have it open? You don't have any outputs on that vi (apart from error cluster)...When you want to have that merged string in your testonly.vi you have to connect the concatenated string to the connector pane (as you did for the input) and create an indicator in testonly.vi too! See attachment!Message Edited by GerdW on 08-13-2008 09:23 PM


testonly_lv82.zip:
http://forums.ni.com/ni/attachments/ni/170/349115/1/testonly_lv82.zip
MrSafe
2008-08-13 19:40:08 UTC
Permalink
After I finish excuting testonly.vi I go into mergstrings and check the values; If I open mergstrings.vi then excute you testonly.vi I see the values in string 1 and the output string.&nbsp;Thank you for the attachment I am looking at it as we speak. Message Edited by MrSafe on 08-13-2008 02:24 PM
GerdW
2008-08-13 19:40:08 UTC
Permalink
Hi MrSafe,&nbsp;LabView doesn't store values in indicators when the front panel is closed (to express it in a simplified version).That's why you don't see new values in mergstring.vi when you open it after executing testonly... In LabView the wire is the variable, not the control/indicator!
MrSafe
2008-08-13 19:40:09 UTC
Permalink
correct me if im wrong but from what you said Labview has the values it simply doesn't show it in the current method I am using?
GerdW
2008-08-13 19:40:09 UTC
Permalink
Hi MrSafe,&nbsp;yes, when opening a vi after execution you will not see the last values! Instead you will find default values...&nbsp;Either set the subvi to open the panel when executing (in the vi properties) or (better option) use a wire as I said before and have shown in the attachment!
MrSafe
2008-08-13 20:40:07 UTC
Permalink
Thank You. I apologize for asking this obvious questions I will continue to read toturials but I am more of lets try and put it to the test type of person where I can fallow the guide as I am doing it on labview. Hands on.
cschneider
2008-08-11 18:10:08 UTC
Permalink
If you know the format of your strings, you can use perhaps the "string subset" vi. You can specify an offset and a length and get a part of a string...in your example, you can split the string 3 into "1" and "#" and then merge them again with string 1 and string 2 using the concatenate string-vi. Hope it helpsChristian
MrSafe
2008-08-11 18:10:09 UTC
Permalink
I will give it a shot thank you. If anyone else has more ideas please let me know no such thing as to much information =D
smercurio_fc
2008-08-11 18:10:09 UTC
Permalink
I still don't see the rules for the merging defined. In your example you have: String A: "Have A" String B: "Nice Day"String C: "#1"and a merged string of "1 Have Nice A Day #". Any particular reason why the 1 is at the beginning? Can the merge look like "Have Nice A Day #1", or "Nice Day Have A #1" or "Nice Day #1 Have A", or "Nice Have # 1 A Day"?
MrSafe
2008-08-11 18:40:07 UTC
Permalink
Well no there is no reason I was trying to give everyone an example of how flexible I need to make sure it is. The reason for this is because I plan on gathering information from a file which will be used as a file name for another.when combined it will not make sense all the time. This file will contain client name standard tracker # etc
unclebump
2008-08-13 19:10:09 UTC
Permalink
For the file path question, look in the FILE IO section on the block diagram. There is a path to string function and path to array of strings function.&nbsp;For the string operations, I would look at replace substring, search and replace substring, and maybe Format into String
Loading...