AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

concatenation
Goto page 1, 2, 3, 4  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
TeeTwo



Joined: 29 Dec 2006
Posts: 123
Location: Australia

PostPosted: Thu Feb 15, 2007 7:21 am    Post subject: concatenation Reply with quote

I have found that AHK runs hand in glove with the basic dialect I use which is Rapidq.
I am pleased that it seems a mixture of c and basic with simple english commands.

It is this mix that I find confusing sometimes and the documentation although a massive work in itself often does not explain simple concepts
for instance adding two strings
in basic this is simple. I have found a way in AHK but
a = abc
b = def
c = a + b
msgbox c ; should = abcdef
it works this way
a = abc
b = def
c = %a%%b%
msgbox %c%

works but not logical >>>I wish!
_________________
(The guy from Oz)


Last edited by TeeTwo on Thu Feb 15, 2007 10:54 am; edited 1 time in total
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 634
Location: LooseChange911.com The WTC bldgs shouldn't have fallen that fast. The official story is a lie!

PostPosted: Thu Feb 15, 2007 10:19 am    Post subject: Re: plus (+) should be concat(enation) Reply with quote

Your subject is useless...it should be...
    plus (+) should be concat(enation)
...but in any case...
...I AGREE...
_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
Grumpy
Guest





PostPosted: Thu Feb 15, 2007 10:30 am    Post subject: Reply with quote

Indeed, I wish you change this subject...
It is like people putting "Help me" as subject in the Help section.
We haven't seen "My Script" in the script section (I didn't, at least), but it is in the same spirit...

Note: You have c = %a%%b%, but also c := a . b, so it has a real concatenation symbol already, no need to change it.
Back to top
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Thu Feb 15, 2007 11:51 pm    Post subject: Reply with quote

Yes, we already have the concatenate operator, and I think that's better than overloading the plus (+) symbol. Unlike some other languages that use it for concatenation, AutoHotkey implicitly converts strings that contain a representation of a number into the number itself:
Code:
x := "23"
y := "8"
MsgBox % x . y  ; 238
MsgBox % x + y  ; 31


Which of the two cases above should '+' perform when both the strings are purely numeric? It's ambiguous, because of AHK's weak typing.

Besides, even without the ambiguity, why not have a separate operator for it? There's much less potential for confusion that way, especially for beginners who may not find '+' as concatenation to be very intuitive.
Back to top
View user's profile Send private message
TeeTwo



Joined: 29 Dec 2006
Posts: 123
Location: Australia

PostPosted: Tue Feb 20, 2007 3:58 am    Post subject: Reply with quote

Thanks for heads up you'r right about subject and I have changed it Sorry Embarassed

It will take me a while as I easily reach for the + as I have gained bad habits not all related to scripting Smile

Thanks for comments especially yours jonny. The others well! I stand corrected.
_________________
(The guy from Oz)
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 634
Location: LooseChange911.com The WTC bldgs shouldn't have fallen that fast. The official story is a lie!

PostPosted: Tue Feb 20, 2007 1:19 pm    Post subject: Reply with quote

jonny wrote:
It's ambiguous, because of AHK's weak typing.

...yes, AHK should receive "typing"...in one of my concat posts I made an example of it...ok I can't find the post, so here...

Code:
x1:="23"
y1:="8"

x2:=23
y2:=8

MsgBox % x1+y1                          ;//238
MsgBox % x2+y2                          ;//31

MsgBox % toNum(x1)+toNum(y1)            ;//31
MsgBox % toString(x2)+toString(y2)      ;//238

jonny wrote:
Besides, even without the ambiguity, why not have a separate operator for it?

...because!...ok not a good enough reason?...well because! anyway...I like plus...I don't care if dot stays, but I want plus for strings too...

TeeTwo wrote:
...as I have gained bad habits...

...I don't see how using plus as concat is a "bad habit"...you are adding strings together, so + = add...you don't "dot" strings together...
_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6836
Location: France (near Paris)

PostPosted: Tue Feb 20, 2007 1:29 pm    Post subject: Reply with quote

JSLover wrote:
you are adding strings together, so + = add...you don't "dot" strings together...
No, you are not adding them, you concatenate them, that's not the same operation. Or why is there a separate word?
Adding two string should be something like:
Code:
s1 = A string
s2 = Another string
l1 := StrLen(s1), l2 := StrLen(s2)
l := l1 > l2 ? l1 : l2
Loop %l%
{
   added .= Chr(Asc(SubStr(s1, A_Index)) + Asc(SubStr(s1, A_Index)))
}
MsgBox %added%
No? With perhaps some constrain on printable Ascii...

When I add 1 and 1, I don't expect to get 11... (10, at worse Smile)
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Wed Feb 21, 2007 3:49 am    Post subject: Reply with quote

I expect to get 0 with the overflow bit set. Razz
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Wed Feb 21, 2007 12:23 pm    Post subject: Reply with quote

I prefer space as concatentation and to leave . for something kewl, like pseudo - classes.

Like, StdLib.MyFunction(...)

or for struct support: myStruct.myField := 4

Well, this can be done even now as "." is not concatenation but " . "

It will be confusing though...
_________________
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Wed Feb 21, 2007 11:15 pm    Post subject: Reply with quote

Wasn't this already discussed? Space as concatenation is horrible programming practice, mostly because it increases the chance of errors, but also because of ambiguity (not logical so much as visual). It doesn't even make much sense: an expression is not a specification for the construction of a string, it is a series of operations that may include data types ranging from numerical to boolean to textual.

Quote:
Well, this can be done even now as "." is not concatenation but " . "

It will be confusing though...


Actually, it can't, '.' not being a legal character in a variable name.

Also, the space padding issue should be seen to fairly soon:
Chris wrote:
Concerning the need for spaces around the dot, .=, and ? operators, I hope to resolve that in v2 (and possibly sooner for the dots).
Back to top
View user's profile Send private message
TeeTwo



Joined: 29 Dec 2006
Posts: 123
Location: Australia

PostPosted: Thu Feb 22, 2007 5:55 am    Post subject: Reply with quote

You sticks your toe in the water and the sharks bite.

I must say I do appreciate this. I am a concatenation of knowledge now.
_________________
(The guy from Oz)
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Thu Feb 22, 2007 11:59 am    Post subject: Reply with quote

majkinetor wrote:
I prefer space as concatentation
What about a concat assign operator?
_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Thu Feb 22, 2007 12:57 pm    Post subject: Reply with quote

we can keep it Razz

jonny wrote:
Actually, it can't, '.' not being a legal character in a variable name.

I didn't mean NOW, like NOW, but NOW like, AHK can be upgraded NOW to treat . as namespace delimiter as it can not be used in variable names and sentence Namespace.Variable is not valid in concatenation context...
_________________
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 2951
Location: Minnesota

PostPosted: Thu Feb 22, 2007 9:54 pm    Post subject: Reply with quote

Ah, I see. However, ideally Ident1.Ident2 would work (as concatenation).
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Fri Feb 23, 2007 12:38 am    Post subject: Reply with quote

jonny wrote:
Ah, I see. However, ideally Ident1.Ident2 would work (as concatenation).
No...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group