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!

copy from windows clipboard or user prompt and convert case 1

Status
Not open for further replies.

malium

ISP
Jun 26, 2003
23
0
0
US
I'd like to be able to copy from Windows clipboard or have a script prompt for user input of a string or strings to use in a script as is, and use stringA a second time with case converted from CAPS to lower case and format changed.

Ideal scenario would be to have it not matter if the copy buffer had upper or lower case and then have the script paste the first instance in UPPER case and the second in lower case - and the second instance may need to move some periods to new positions,

Ideally:
- 1) User copies MAC address to Windows buffer - in format 0090.XXXX.ABC3 or 0090.XXXX.abc3, (though in really all that is unique is the last 6 characters so that's probably all I really need to copy, paste and convert),

- 2) string is pasted in UPPER case no matter case it was entered in, then (3) pasted again in a reformatted instance such as 0100.90xx.xxxx.xx with a 01 prefix added to the string and any text characters converted to lower case.

I'm leaning to thinking a user prompt for input may be ideal as I could probably use that to also prompt for an IP address to assign, or maybe pull the highest IP from a parsed file such as the one I'd like to create in my other posted question. Then again, automation of the process would work best if all the user needed was to copy a single string and have the script do the rest and parse the second string from a file.

Suggestions on any of scenarios below would be welcome:

i.e. (A) copy from clipboard as is to script,
(B)from clipboard with parsed case shifts and hopefully also format changes to locations of the . in the addresses,
(C) ability to prompt for user input for one or more strings to be inserted and if possible also have case shifts and format changes applied as needed
(D) pull the two needed strings from a text file or HTML form to use as in C with various cases and formats
(E) parsing a text file of IP addresses to find the highest existing IP and increment +1 to insert as a string.

I think one place I've worked previously did a lot of this in Perl on Unix and with telnet. I'd like to handle as much as possible in Procomm.

Also, related to strings from Windows clipboard, another place I worked used Procomm scripts to grab a site ID number from Windows clipboard, then used this to lookup a related IP or phone number to connect to and initiate the connection.

This was nice but also cleared the Windows clipboard buffer when the string was grabbed - is this typical behavior of the use of strings from the clipboard? Or were they maybe doing something else like a custom DLL to grab the clipboard and do lookups that converted to dial scripts?

And re: cliptostr - is that for Procomm clipboard vs. Windows clipboard? I had the impression there is a copy buffer in Procomm separate from Windows clipboard copy buffer.

I know, I'm asking a lot of things and the last is probably a RTFM but I'm trying to visualize this as I post and that just brings more questions and ideas. As a newbie to Aspect I have a lot to learn. I'm pleased to have rediscovered Procomm, it's great so far and the script capture and edit features have already done much of what I need. I remember using Procomm when I was on BBS systems a lot in the mid-to-late 1980s - it has come a long way since then.

- mal

 
Here are a couple answers to your questions:

Cliptostr manipulates data on the Windows clipboard. The data it copies from the clipboard will remain there afterwards.

You can use the strupr command to convert the contents of a string to all uppercase and the strlwr command to make it lowercase.

aspect@aspectscripting.com
 
thanks - this is useful info. I always thought the thing I'd seen with the paste clearing the windows buffer to be an odd and atypical thing that wasn't necessary, which is why I assumed that was done in a custom DLL or program when it grabbed that string to look up a dial string from a database.

Is there an easy way to convert the format of the string also - i.e. XXXX.XXXX to xx.xxxx.xx when I use the strupr command to convert the contents of a string to all uppercase and the strlwr to lower? I'm guessing that's going to take breaking the string down to smaller strings of pairs or single characters to reformat the period placement - i.e. in steps - convert string to lower case, break it into 4 pairs (aabb.ccdd) and then reconstruct the pairs in the desired aa.bbcc.dd format.

Also, this is data that is mixed alpha numberical data - I'm assuming that the strlwr and strupr would leave characters 1-9 as is when converting?
 
The strupr and strlwr command only act on the characters A-Z and a-z, so all other characters in the string will be left as-is.

Here is a snippet that takes a string in the format AAAA.BBBB and outputs AA.AABB.BB. This will only work if the string is 9 characters long (i.e. no missing digits).

proc main
string sLine = "AAAA.BBBB"

strdelete sLine 4 1
strinsert sLine "." 2
strinsert sLine "." 7
endproc

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top