Sign in to follow this  
Followers 0
blahole

C++ to Autoit Porting Help

6 posts in this topic

Hi,

I'm trying to port some C++ code to autoit and I'm not sure exactly what, if any, support autoit has for manipulating ascii characters via addition and subtraction.

The C++ code I'm trying to port is similiar to the following:

------------------------------------------------------------------------------------

register const char *str = "242142342352523502352" or something similiar

static unsigned short asso_values[] = { 308, 308, 308, 308, 308, 308, 308, 308, etc}

return len + asso_values[(unsigned char)str[19]+5] + asso_values[(unsigned char)str[17]+2] + asso_values[(unsigned char)str[16]] + asso_values[(unsigned char)str[6]];

------------------------------------------------------------------------------------

I'm not sure what the best approach would be to port this code to autoit. I looked through some of the string functions and I've tried to add and subtract from single characters and I don't get the correct ascii characters that I should. Anyone have any suggestions?

I would really appreciate any help you guys could provide as I'm pretty new to autoit so I'm just trying to familiarize myself with all of the functions and syntax and whatnot.

Thanks!

Share this post


Link to post
Share on other sites



Hi..

so.. if you like to add and subtract from characters to get another char..

you have to look in the helpfile.. :-) Theres a section "Variables an Conversions"

The functions interressting for you, would be Asc() and Chr()..

..an example:

$var1="a"                       ;a var containing "a"
$var2=Chr(Asc($var1)+1) ; change "a" to "b"  :-)

mfg Domonoky

Share this post


Link to post
Share on other sites

sweet thanks a ton! I was wondering do you also think that the best way to access a character in a string is to use the StringMid function?

Thanks!

Hi..

so.. if you like to add and subtract from characters to get another char..

you have to look in the helpfile.. :-) Theres a section "Variables an  Conversions"

The functions interressting for you, would be Asc() and Chr()..

..an example:

$var1="a"                      ;a var containing "a"
$var2=Chr(Asc($var1)+1); change "a" to "b"  :-)

mfg Domonoky

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

sweet thanks a ton! I was wondering do you also think that the best way to access a character in a string is to use the StringMid function?

Thanks!

<{POST_SNAPBACK}>

Getscreen ($a)
$blah = StringStripWS(ClipGet(), 8)
$tem = StringInStr($blah, "PRV#:")
$prov = StringRight(StringMid($blah, $tem, 15), 6)

StringInStr returns the numeric location of the string pattern you're looking for.

StringMid will return the actual string.

Some code from one of my programs demonstrating my use of StringInStr() and StringMid() within AutoIt. String manipulation is all I am doing right now with this code base.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Hi..

jeah.. i think the best way to replace the c++ way of accessing singel chars would be the stringMid() function..

char -> stringmid($char,$i,1)

mfg Domonoky

Share this post


Link to post
Share on other sites

Ok thanks a lot for the help everyone!

Hi..

jeah.. i think the best way to replace the c++ way of accessing singel chars would be the stringMid() function..

char  ->  stringmid($char,$i,1)

mfg Domonoky

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0