Jump to content



Photo

Creating text from array data. [Solved]

Arrays ClipPut Drives

  • Please log in to reply
8 replies to this topic

#1 blckpythn

blckpythn

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 06 August 2012 - 10:34 PM

Hey guys, back from the grave here(long time no see)

I've got a little utility for many of my clients to see and copy-to-clipboard basic computer information for our ticketing system.

In this script I want to include any mapped drives during the ClipPut command.

Unfortunately I'm not quite sure how to enumerate and convert to text these drives. I can get them to print to console just fine, but I want to include in the ClipPut function.


Here is the jist of it.

$drives = DriveGetDrive("NETWORK") If @error Then ConsoleWrite("An error occured while retrieving the drives.") Else For $i = 1 To $drives[0] ConsoleWrite(StringUpper($drives[$i]) & " " & DriveMapGet($drives[$i]) & @CRLF) Next EndIf Func Copy() ClipPut("Drives: " & ) EndFunc ;==>Copy


Forgive me if I screwed up the autoit-in-forum tags.

So at the 3rd to last line after "Drives: " I want it to show each drive letter and path like the ConsoleWrite command does.

Any ideas of how to do this without manhandling an array value repeatedly?
I'm assuming there has to be a way to do a For...To loop within the ClipPut parenthesis, yes?

Edited by blckpythn, 07 August 2012 - 02:54 PM.








#2 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,760 posts

Posted 07 August 2012 - 06:54 AM

After that press CTRL+V

Local $drives = DriveGetDrive("NETWORK") Local $tmp If @error Then ConsoleWrite("An error occured while retrieving the drives.") Else For $i = 1 To $drives[0] ;~ ConsoleWrite(StringUpper($drives[$i]) & " " & DriveMapGet($drives[$i]) & @CRLF) $tmp &= StringUpper($drives[$i]) & " " & DriveMapGet($drives[$i]) & @CRLF Next ClipPut($tmp) EndIf

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#3 blckpythn

blckpythn

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 07 August 2012 - 02:05 PM

Ah, thank you! That makes so much sense.

#4 blckpythn

blckpythn

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 07 August 2012 - 02:18 PM

Unfortunately I'm now getting a syntax error at the end of the @CRLF, says it's missing Next. If I put Next on the same line then it says my EndFunc is ending the For loop.

#5 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,760 posts

Posted 07 August 2012 - 02:34 PM

Show your code, please.

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#6 blckpythn

blckpythn

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 07 August 2012 - 02:46 PM

Show your code, please.

$drives = DriveGetDrive("NETWORK") $clipboard = "" For $i = 1 To $drives[0] $clipboard &= StringUpper($drives[$i] & " " & DriveMapGet($drives[$i]) & @CRLF Next $clipboard &= "[/code]" ClipPut($clipboard)


#7 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,760 posts

Posted 07 August 2012 - 02:48 PM

$drives = DriveGetDrive("NETWORK") $clipboard = "" For $i = 1 To $drives[0] $clipboard &= StringUpper($drives[$i]) & " " & DriveMapGet($drives[$i]) & @CRLF Next $clipboard &= "[/code]" ClipPut($clipboard)


You forgot to close the ) from StringUpper.

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#8 blckpythn

blckpythn

    Wayfarer

  • Active Members
  • Pip
  • 76 posts

Posted 07 August 2012 - 02:53 PM

Ha, thank you, I feel stupid.

#9 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,760 posts

Posted 07 August 2012 - 03:35 PM

Little mistake, nothing really stupid.
Glad I could help.

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users