Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Aug 15, 2018 2:11 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: String Remove
PostPosted: Fri Mar 15, 2013 4:12 am 
Offline

Joined: Thu Mar 14, 2013 1:15 pm
Posts: 6
how to remove string line?

dim test as string
msgbox test
// print result
test1
test2
test3

how to remove test2 line?
how to remove line in string?

_________________
osx user


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 5:17 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
test = replace (test,"test2" + endofline,"")

You may need to experiment with the endofline bit: it may need to be a Mac style, or a Windows style


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 5:29 am 
Offline

Joined: Thu Mar 14, 2013 1:15 pm
Posts: 6
kermit wrote:
test = replace (test,"test2" + endofline,"")

You may need to experiment with the endofline bit: it may need to be a Mac style, or a Windows style

this string is example and not work.
my string is random and i want remove line

second question

dim sh as Shell
sh=new Shell
sh.Execute "logname"
dim tm as string
tm=sh.Result+"!!!"
dim test as string
test=Replace(tm,EndOfLine,"")
MsgBox test

//// print
alex
!!!

i want print alex!!!

sorry my bad english
thanks kermit :)

_________________
osx user


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 6:49 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
I altered your code a bit to shrink it down and added a check to see if the shell succeeded or not, hope it works for you :)
Dim sh as New Shell

sh.Execute("logname")
if sh.ErrorCode = 0 then
MsgBox Trim(sh.Result) + "!!!"
else
//Shell command failed
MsgBox "Error: " + Str(sh.ErrorCode)
end if
sh.Close

I used the Trim() function to get rid of the EndOfLine thingy.

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 8:44 am 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
You can also use ReplaceLineEndings( s, "" )

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 8:49 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
programmer-alex wrote:
kermit wrote:
test = replace (test,"test2" + endofline,"")

You may need to experiment with the endofline bit: it may need to be a Mac style, or a Windows style

this string is example and not work.
my string is random and i want remove line

Do you always want to remove the second line regardless of its content?

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 9:43 am 
Offline

Joined: Thu Mar 14, 2013 1:15 pm
Posts: 6
Akiland wrote:
programmer-alex wrote:
kermit wrote:
test = replace (test,"test2" + endofline,"")

You may need to experiment with the endofline bit: it may need to be a Mac style, or a Windows style

this string is example and not work.
my string is random and i want remove line

Do you always want to remove the second line regardless of its content?

yes

Akiland wrote:
I altered your code a bit to shrink it down and added a check to see if the shell succeeded or not, hope it works for you :)
Dim sh as New Shell

sh.Execute("logname")
if sh.ErrorCode = 0 then
MsgBox Trim(sh.Result) + "!!!"
else
//Shell command failed
MsgBox "Error: " + Str(sh.ErrorCode)
end if
sh.Close

I used the Trim() function to get rid of the EndOfLine thingy.

is not work!
ktekinay wrote:
You can also use ReplaceLineEndings( s, "" )

thanks.
second way --> str=Replace(shell.Result,chr(10),"")

// i need help first question
how to remove line

_________________
osx user


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 12:09 pm 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Quote:
//// print
alex
!!!

i want print alex!!!


dim sh as new Shell
sh.Execute "logname"
msgbox replaceb(sh.result,chrb(10),"") + "!!!"


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Fri Mar 15, 2013 8:23 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
I'm not sure I understand what you need, so let me give you an example of what I think you want. Tell me if I'm right.

Let's say you have this string:
s = "a" + EndOfLine + "b" + EndOfLine + "c"

You want to be able to remove, say, the second line so the string becomes:

a
c

Right?

This code would do that:
Function RemoveParagraph(s As String, num As Integer) As String
dim pars() as string = s.Split( EndOfLine )
pars.Remove( num - 1)
return join( pars, EndOfLine )
End Function

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: String Remove
PostPosted: Sat Mar 16, 2013 2:23 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Some of the confusion is down to language.
Some, I am sure , was due to the OP using !!! as part of the string

If he had used "... is a great guy" instead, it makes more sense

Then his output becomes

alex
...is a great guy


but he wanted it to be

alex..is a great guy


The use of !!! all over the place made it look like he was very emphatic about what he wanted to see.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group