Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Enter in string 2

Status
Not open for further replies.

TariqMehmod

Programmer
Mar 4, 2004
100
PK
Sir I am trying to send message on whatsapp with following codes

Code:
 Declare  Integer FindWindow In WIN32API String , String
Declare  Integer SetForegroundWindow In WIN32API Integer
Declare  Integer  ShowWindow  In WIN32API Integer , Integer
Declare Integer ShellExecute In shell32.Dll ;
	INTEGER hndWin, ;
	STRING cAction, ;
	STRING cFileName, ;
	STRING cParams, ;
	STRING cDir, ;
	INTEGER nShowWin

Local lt, lhwnd

cPhone=[923000000000]
cMessage='How are you sir?'+SPACE(2)+'what are you doing'


comando='whatsapp://send?phone=&cPhone&text=&cMessage'


=ShellExecute(0, 'open', comando,'', '', 1)

Wait "" Timeout 3
lt = "Whatsapp"
lhwnd = FindWindow (0, lt)
If lhwnd!= 0 					
	SetForegroundWindow (lhwnd) 
	ShowWindow (lhwnd, 1)
	ox = Createobject ( "Wscript.Shell" )
	ox.sendKeys ( '{ENTER}' )
	*Messagebox ( "Message Sent" )
Else
	Messagebox ( "Whatsapp no activated!" )
Endif

The command work fine, no issue
But I want to send above message into 2 lines so I add CRLF

Code:
#define CRLF CHR(13)+CHR(10)
cMessage='How are you sir?'+CRLF+'what are you doing'

When I run command is says

command contains unrecognized command phrase/keyword

Please help me to send above message in 2 lines like this
msg_khxfak.png


Regards
 
Sir I posted correct codes

The message is delivered in single line on whatsapp but I want to send it into 2 lines so I used CRLF

You can run this prg with you pc+whatsapp

when I use this line
Code:
cMessage='How are you sir?'+SPACE(2)+'what are you doing'

then no issue
but when I use this line
Code:
#define CRLF CHR(13)+CHR(10)
cMessage='How are you sir?'+CRLF+'what are you doing'

then it shows error


Please
 
OK, I've just run your entire code. The error does NOT occur on the line that you showed. It occurs on this line:

Code:
comando='whatsapp://send?phone=&cPhone&text=&cMessage'

That's because you are macro-expanding cMessage, and the CRLF causes the macro expansion to stop. You need to do something like this:

Code:
comando='whatsapp://send?phone=&cPhone&text=How are you sir?'+CRLF+'what are you doing'

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks sir for helping

your wrote

Code:
 comando='whatsapp://send?phone=&cPhone&text=How are you sir?'+CRLF+'what are you doing'

you added CRLF in above command

is it possible to add CRLF in variable &cMessage because I am adding message into command string from variable.

Please
 
You can't put CRLF in &cMessage, because &cMessage is a macro - not a variable. However, there is no reason to use a macro in this case. You could simply do this instead:

Code:
#define CRLF CHR(13)+CHR(10)
cMessage='How are you sir?'+CRLF+'what are you doing' 
comando='whatsapp://send?phone=&cPhone&text=' + cMessage

Of course, while that will get rid of your syntax error, I have no way of knowing how Whatsapp will interpret it. You may need some different way of inserting a line break in a Whatsapp message. But try the above and let us know if it works.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Like this:
Code:
whatsapp://send?phone=02084418979&text=%0a‎Hello%0aWorld


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
So, to combine Griff's suggestion with Tariq's original code:

Code:
cMessage='How are you sir?[highlight #EDD400]%0a[/highlight]what are you doing' 
comando='whatsapp://send?phone=&cPhone&text=' + cMessage

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Exactly Mike.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Not sure about the &cPhone
Code:
cMessage='How are you sir?%0awhat are you doing' 
comando='whatsapp://send?phone='+cPhone+'&text=' + cMessage

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
I think &cPhone should be OK because it just contains a string of digits. But I agree. Better to eliminate it. The whole thing's a bit creaky, because he was using an ampersand both to flag a VFP macro, and as a parameter separator in the URL:

comando='whatsapp://send?phone=[highlight #EDD400]&[/highlight]cPhone[highlight #73D216]&[/highlight]text=' + cMessage

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
That's interesting, that VFP would expand the first macro expression, but not error when the second one doesn't expand.

That is not behaviour I would have expected.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Thanks sir GriffMG and Mikewis

Now with these codes messages are going in multiple lines

Code:
*#define CRLF CHR(13)+CHR(10)
*cMessage='How are you sir?%0awhat are you doing?'

crlf_lofsvb.png


But issue is in unicode, I am trying to send message in Urdu language like

Code:
cMessage=[ÇÓáÇã Úáí˜ã];
+' a0% '+;
[ÓÑ ˜íÓÿ ÀíŸ]
comando='whatsapp://send?phone=&cPhone&text=' + cMessage

When I send message then appears like this
crlf3_fiquwd.png


The original messages are like below
crlf2_uupgjc.png


Please help
 
Your Urdu string contains a0%. Try changing it to %0A.

(I know that Urdu is written right-to-left, but I think the URL encoding should go left to right. Someone will correct me if i am wrong about that.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well spotted

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Dear all participants,

Thanks for helping all problem solved.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top