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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cliptostr then transmit sending <CR> as part of string? 1

Status
Not open for further replies.

malium

ISP
Jun 26, 2003
23
0
0
US
Looks like I'm seeing a string I pull from the Windows clipboard causing occasional early execution of the line I am trying to construct and transmit. I think it's coming from a <CR> at end of the highlighted string and it's difficult in windows sometimes to copy a string at the end of a line - you can't see if you are including a hidden <CR> in the copied data.

Any help or suggestions welcomed. Here's what I am using now:

;RESET Modem using ID data from clipboard
proc main
string endOfMAC ; set string from the clipboard looking for XX.XXXX
usermsg &quot;RESET MODEM: Highlight last 6 digits of MAC in format XX.XXXX.&quot;
cliptostr endOfMAC ; copy mixed alpha-numeric string from the clipboard
strlwr endOfMAC ; convert string to lower case
transmit &quot;^M&quot;
waitfor &quot;#&quot; ; make sure command prompt is ready

; transmits constructed string &quot;clear cable modem 0090.83xx.xxxx reset^M&quot;
; occasional problem seems to be <CR> captured in end of paste string
; causes command to execute as &quot;clear cable modem 0090.83xx.xxxx^M&quot; then &quot; reset^M&quot;

transmit &quot;clear cable modem 0090.83&quot;
transmit endOfMAC
transmit &quot; reset^M&quot;

pause 1
waitfor &quot;#&quot;
pause 2
usermsg &quot;Modem RESET completed&quot; ; ack completed process
;pwexit ; uncomment to autoclose session if desired
endproc

I think what I need to do is strip the <CR>. Even better I'd love to be able to validate the string is the correct format of XX.XXXX and pop a usermsg to copy the data to clipboard again if it doesn't fit that template, but I have no idea how to do this.

Is there a way to construct a transmit command using multiple strings on one transmit line?
for example:
transmit &quot;xxxxxxxx&quot;String &quot;xxxxxxxx&quot;

Or am corect in assuming I need to do multiple transmit lines to construct the line I want? I'm guessing I could probably also constrcut a larger string incorporating the cliptostr in it but didn't know how and this seems to do what I need. And I'd probably have the same issue with a hidden ^M in the string anyway.
 
There is no way to transmit multiple strings with one transmit command, but you can use some commands such as strfmt or strcat to combine several strings into one string and then transmit that.

To remove any carriage returns from the string copied from the clipboard, you can use this command:

strreplace endOfMAC &quot;`r&quot; &quot;&quot;

aspect@aspectscripting.com
 
Thanks! That looks like exactly what I was looking for. I appreciate the tips on string combining also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top