Split multiple lines of string in separate string
Split multiple lines of string in separate string
(OP)
Shortly, I want to make a spelling checker for text in drawings.
The problem that I have is that most of my text is made of multiple lines.
How can I split the multiple lines of text in separate strings (catscript)?
I was thinking that something like this should work, but it doesn't:
array = Split(text, ""vbcrlf")
I want to make from multiple lines of text, single lines of text and after that I will be able to compare the text from the drawings with some .txt files.
Any kind of help is highly appreciated.
PS
I use Catia V5.R16 on a Unix workstation.
The problem that I have is that most of my text is made of multiple lines.
How can I split the multiple lines of text in separate strings (catscript)?
I was thinking that something like this should work, but it doesn't:
array = Split(text, ""vbcrlf")
I want to make from multiple lines of text, single lines of text and after that I will be able to compare the text from the drawings with some .txt files.
Any kind of help is highly appreciated.
PS
I use Catia V5.R16 on a Unix workstation.





RE: Split multiple lines of string in separate string
CODE --> catvbs
Sub CATMain() Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Temp\Your_test_file.txt", 1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine MsgBox strLine Loop objFile.Close End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Split multiple lines of string in separate string
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Split multiple lines of string in separate string
RE: Split multiple lines of string in separate string
I have some text from a database that I can save it as .txt file. This is my master text that I know that is good.
I can read this text file using a V5 catscript and I made an array with all of this text.
Now I need to compare the text that is added manually in some V5 drawings with the master text from the array.
I can loop through all of the existing views and texts from V5 drawings, in order to compare it with my master array but I have a problem.
Some of the text from the V5 drawings is made from multiple lines of text and each line of text represent one element that I need to check.
For example I can see in the V5 drawing, a text line this:
text1
text2
When I read with the catscript above text, it gives me a single string with two lines.
I would like to make from this string with two lines, two separate strings that I can compare with my master array.
I was thinking that I can make from a string with two lines, two separate strings using the split function:
array = Split(text, ""vbcrlf"), using as separator the new line "vbcrlf". I do not understand why this does not work.
This is my question, probably it seems stupid, I do not know how to split a string with many lines.
RE: Split multiple lines of string in separate string
Now I want to do it it the other way around, to take the text from the database and manipulate it with the V5 catscript.
RE: Split multiple lines of string in separate string
RE: Split multiple lines of string in separate string
array = Split(text, vbcrlf)
RE: Split multiple lines of string in separate string
I attached a example drawing and this is the code that I had used:
CODE -->
Please, take a look and help me :)
By using this code I need to see two message box with this text: 5285VB/1M and 3397VC1-A.
What am I doing wrong?
RE: Split multiple lines of string in separate string
Not a simple solution but is working
CODE --> CATScript
Sub CATMain() Dim arrManyLines Set oDrwDocument = CATIA.ActiveDocument Set oDrwView = oDrwDocument.Sheets.Item(1).views For i = 1 To oDrwView.Count Set CurrentView = oDrwView.Item(i) 'Skip the background view (Title block) If CurrentView.Name <> "ZR" Then For j = 1 To oDrwView.Item(i).Texts.Count 'Scan all the Texts of the Views strText = oDrwView.Item(i).Texts.Item(j).Text MsgBox strText '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Create temporary file Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") Dim sTemp : sTemp = fso.GetSpecialFolder(2) & "\" & fso.GetTempName MsgBox sTemp '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''Write in temporary file Dim oFile : Set oFile = fso.CreateTextFile(sTemp, True) oFile.Write strText oFile.Close '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''Read lines in temporary file Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(sTemp, 1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine MsgBox strLine Loop objFile.Close '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Clean up fso.DeleteFile sTemp Set fso = Nothing Set objFSO = Nothing Next End If Next End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Split multiple lines of string in separate string
I lost a few hours in order to find a solution and I didn't.
Thank you for your solution, it is exactly what I need.
RE: Split multiple lines of string in separate string