TheAutomator Posted September 17, 2016 Posted September 17, 2016 (edited) Hi people, It's been a while I have been scripting in vbscript for some time but now i'm back using AutoIt for a project: Scripting Adobe Illustrator with AutoIt . This vb code needs to be converted: Set appRef = CreateObject("Illustrator.Application") 'Create a new document and assign it to a variable Set documentRef = appRef.Documents.Add 'Create a new text frame item and assign it to a variable Set sampleText = documentRef.TextFrames.Add 'Set the contents and position of the TextFrame sampleText.Position = Array(200, 200) sampleText.Contents = "Hello World!" The ... = Array(200,200) part is done in one line in vb, is this possible in AutoIt without declaring an array first? I know I sound like a newbie but I never had to use arrays this way before.. what i have: $appRef = ObjCreate("Illustrator.Application") ;Create a new document and assign it to a variable $documentRef = $appRef.Documents.Add ;Create a new text frame item and assign it to a variable $sampleText = $documentRef.TextFrames.Add ;Set the contents and position of the TextFrame ReDim $sampleText.Position[2] = [200, 200] <<<--- doesn't work... $sampleText.Contents = "Hello World!" Edited September 17, 2016 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
Gianni Posted September 17, 2016 Posted September 17, 2016 maybe you could "simulate" the VB behaviuor for "Array()" by using a simple function to return a 2 elements array.... $appRef = ObjCreate("Illustrator.Application") ;Create a new document and assign it to a variable $documentRef = $appRef.Documents.Add ;Create a new text frame item and assign it to a variable $sampleText = $documentRef.TextFrames.Add ;Set the contents and position of the TextFrame $sampleText.Position = Array(200, 200) $sampleText.Contents = "Hello World!" Func Array($iX, $iY) ; returns a 2 element 1d array Local $aArray[2] = [$iX, $iY] Return $aArray EndFunc ;==>Array Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
TheAutomator Posted September 17, 2016 Author Posted September 17, 2016 7 minutes ago, Chimp said: maybe you could "simulate" the VB behaviuor for "Array()" by using a simple function to return a 2 elements array.... $appRef = ObjCreate("Illustrator.Application") ;Create a new document and assign it to a variable $documentRef = $appRef.Documents.Add ;Create a new text frame item and assign it to a variable $sampleText = $documentRef.TextFrames.Add ;Set the contents and position of the TextFrame $sampleText.Position = Array(200, 200) $sampleText.Contents = "Hello World!" Func Array($iX, $iY) ; returns a 2 element 1d array Local $aArray[2] = [$iX, $iY] Return $aArray EndFunc ;==>Array Yes, I thought about that to.. but I first wanted to know if there wasn't a more direct way. I suppose that's a no for direct array declaring in AutoIt then? Thanks for the reply btw Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
czardas Posted September 17, 2016 Posted September 17, 2016 (edited) 11 minutes ago, TheAutomator said: I suppose that's a no for direct array declaring in AutoIt then? Correct in relation to your syntax, although using StringSplit() should also work here - however this is still calling a function. Edited September 17, 2016 by czardas operator64 ArrayWorkshop
Gianni Posted September 17, 2016 Posted September 17, 2016 good point, so you could use for example something like this; $sampleText.Position = StringSplit('200,200', ',', 3) p.s. ( little hijacking) ) @czardas, Since also the StringRegExp function can return an array, what pattern can be used to have an array from a comma delimited list? .....thanks Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
czardas Posted September 17, 2016 Posted September 17, 2016 28 minutes ago, Chimp said: what pattern can be used to have an array from a comma delimited list? I think I know this. _ArrayDisplay(StringRegExp("200,200", '[^,]+', 3)) operator64 ArrayWorkshop
Danyfirex Posted September 17, 2016 Posted September 17, 2016 Hello. knowing that we're going to use number also we could use _ArrayDisplay(StringRegExp("200,200", '\d+', 3)) Of course for this Chimp's suggestion is the correct/clean way to use. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Gianni Posted September 17, 2016 Posted September 17, 2016 5 minutes ago, czardas said: I think I know this. never doubted ...... lol @Danyfirex .... thanks p.s. is there any 'regexp' guru that could came out with an an esotheric pattern to get a multidimensional array as well..... czardas 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
czardas Posted September 17, 2016 Posted September 17, 2016 2 hours ago, Chimp said: never doubted Well as long as there are no missing items in the list, the regexp is fine. operator64 ArrayWorkshop
aiter Posted September 17, 2016 Posted September 17, 2016 redim $sample.text.position[200][200] arrays are [x][y] not [x,y] Just my humble 2 cents
TheAutomator Posted September 18, 2016 Author Posted September 18, 2016 17 hours ago, aiter said: redim $sample.text.position[200][200] arrays are [x][y] not [x,y] Just my humble 2 cents Still doesn't work like this tho, but thanks for the tip Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now