Sign in to follow this  
Followers 0
PERTU

Some questions about _ArrayDisplay.

14 posts in this topic

Hi,

I have some questions about _ArrayDisplay, I searched the help file and forums but couldn't find my answers.

  • What does the "TextSelected" button do, and how to use it?
  • How can I have the "Close" button preselected when the _ArrayDisplay window open?
  • Is it possible to NOT display row 0?
  • Is it possible to add some text between the titlebar and the table?
  • How can I resize the window?
Thank you,

Olivier.

Share this post


Link to post
Share on other sites



Hi,

I have some questions about _ArrayDisplay, I searched the help file and forums but couldn't find my answers.

  • What does the "TextSelected" button do, and how to use it?
  • How can I have the "Close" button preselected when the _ArrayDisplay window open?
  • Is it possible to NOT display row 0?
  • Is it possible to add some text between the titlebar and the table?
  • How can I resize the window?
Thank you,

Olivier.

1 - TextSelected = copy into clipboard; if nothing selected entire array is copied. I only know this after emailing randell and made the suggestion to him to make the button text mo' betta sos wez idiots knows whaz its means.

For the rest of your questions, 2 choices come to mind. Modify the array.au3 file to accomplish your goal or make your own gui to do what you want or need. This is exactly what I did in my HexReplacements post. Look at the section of code that begins with _Results.

Hope this answers your questions, welcome to autoit, and good luck!

Share this post


Link to post
Share on other sites

1 - TextSelected = copy into clipboard; if nothing selected entire array is copied. I only know this after emailing randell and made the suggestion to him to make the button text mo' betta sos wez idiots knows whaz its means.

For the rest of your questions, 2 choices come to mind. Modify the array.au3 file to accomplish your goal or make your own gui to do what you want or need. This is exactly what I did in my HexReplacements post. Look at the section of code that begins with _Results.

Hope this answers your questions, welcome to autoit, and good luck!

Hey ssubirias3,

I'll definately try TextSelected and the clipboard. It might be just what I needed for my script. For your other suggestions, about modifying array.au3 and a custom GUI, I'll pass. This is too complicated for me right now. To be honest, I don't really need these things in my script. It would have been sweet to implement it, but it is mostly eye candy.

If anyone have a simple solution for question 2 to 4, i'd like to hear about it, if not, no big deal, but it would be interesting to know.

Thanks,

Olivier.

Share this post


Link to post
Share on other sites

I tried TextSelected and it put it to the clipBoard like you said. But I need the selection to be in an array. Is there an easy way of doing this? I tried searching for ClipToArray or StringToArray but I couldnt find those functions.

Thanks,

Olivier.

Share this post


Link to post
Share on other sites

I tried TextSelected and it put it to the clipBoard like you said. But I need the selection to be in an array. ....

Hmmm.... I'm confused. You have an array that has information you want copied into the clipboard ... but the selection needs to be in an array. Its already in an array, so are you asking how to move certain elements of one array into a second array? Perhaps if you told us what your trying to accomplish and what code you have thus far that would help?

To move parts of an array to a second array you could do something like $avTwo[0] = $avOne[5]. That assuming the 6th row in an array that has data and you want to move to the 1st row of your second array. If you want it _ArrayDisplay to do this for you, you're out of luck unless you modify array.au3 or create your own gui.

Amazing how all roads lead to Rome. Meaning you can ask the same question a hundred different ways and the answer will always be the same. :)

Share this post


Link to post
Share on other sites

Hmmm.... I'm confused. You have an array that has information you want copied into the clipboard ... but the selection needs to be in an array. Its already in an array, so are you asking how to move certain elements of one array into a second array? Perhaps if you told us what your trying to accomplish and what code you have thus far that would help?

To move parts of an array to a second array you could do something like $avTwo[0] = $avOne[5]. That assuming the 6th row in an array that has data and you want to move to the 1st row of your second array. If you want it _ArrayDisplay to do this for you, you're out of luck unless you modify array.au3 or create your own gui.

Amazing how all roads lead to Rome. Meaning you can ask the same question a hundred different ways and the answer will always be the same. :)

Hi,

What my script does is move certain files to a new directory based on information I input into some input box. The script find those files automatically based on the input I give. But if for some reason the script is not able to find the file I want. The script does a _FileListToArray to allow me to manually select the files I want to be moved. I'd like to be able to select some files from the _ArrayDisplay window, click on TextSelected, and when I click on the close button, I want the script to move those files. I don't know how to move files based on filenames that are stored on the clipboard. So I tought It would be best to store those filenames in an array instead, and work from there.

There is the script I got so far. Some part are in french. Look for this line of comment in the script: ";I want to move the file that are listed in $selframes to $dirrenderset & "\*.tga"", this is where I am stuck.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.9
 Author:         PERTU
 Credits:       I got the help of those people from AutoIt forum. BugFix, SmOke_N, Paulie, evilertoaster, PsaltyDS, ssubirias3

 Script Function:   MoveRenderset

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#Include <File.au3>
#Include <Array.au3>
#include <string.au3>

$defepisode = IniRead(@ScriptDir & "\MoveRenderset.ini", "Parameters", "LastUsedEpisode", "aa") ;Lecture du denier episode dans le .ini

$dir = "E:\usadata000"

$defscene = "1"

While 1

$episode = InputBox("MoveRenderset", "Quel épisode?", $defepisode , "")
If @Error=1 Then
    Exit
EndIf
$episode = StringRight( $episode , 2)

IniWrite(@ScriptDir & "\MoveRenderset.ini", "Parameters", "LastUsedEpisode", $episode)




$direpisode = $dir & "\" & "go_" & $episode
_FileListToArray($direpisode)
If @Error=1 Then
    _FileWriteLog(@ScriptDir & "\MoveRenderset.log"," L'épisode " & $episode & " est introuvable" & @CR & @CR & @CR)
    MsgBox (16,"MoveRenderset","L'épisode " & $episode & " est introuvable")
    Exit
EndIf

$scene = InputBox("MoveRenderset", "Quel scène?", $defscene , "")
If @Error=1 Then
    Exit
EndIf

; Vérifie si la scène contient une lettre et trouve le numéro de scène.
$scene = "00" & $scene  
$digit = StringIsDigit($scene)
If $digit = 1 Then
$scene = StringRight($scene, 3)
Else
$scene = StringRight($scene, 4)
EndIf


$dirscene = $direpisode & "\scene-" & $scene

$dirframes = $dirscene & "\frames"

$dirstage = $dirscene & "\stage"



_FileListToArray($dirscene)
If @Error=1 Then
    _FileWriteLog(@ScriptDir & "\MoveRenderset.log"," La scene " & $scene & " est introuvable" & @CR & @CR & @CR)
    MsgBox (16,"MoveRenderset","La scene " & $scene & " est introuvable")
    Exit
EndIf

$ArFrames = _FileListToArray($dirframes)

$frames = _ArrayToString( $ArFrames,@TAB, 0, 0 )



If @Error=1 Then
    MsgBox (16,"MoveRenderset","Le dossier ""frames"" est vide")
    Exit
EndIf

; Déterminer la version de la scène
$ArVersion = _FileListToArray($dirstage)
For $i = 0 To UBound($ArVersion)-1
        $number = _StringBetween($ArVersion[$i], 'v', '.')
        If IsArray($number) Then
        $ArVersion[$i] = Number($number[0]) 
    EndIf
    Next
$version = StringRight('00' &  _ArrayMax($ArVersion, 1), 3 )



$dirrenderset = "E:\Renderset\" & $episode & "\" & $episode & $scene & "_" & $version

DirCreate($dirrenderset)


$filename = $episode & $scene & "_" & $version & "-" & "*.tga"


FileMove($dirframes & "\" & $filename, $dirrenderset & "\*.tga")
$ArFrames = _FileListToArray($dirrenderset)

If @Error=4 Then
    _FileWriteLog(@ScriptDir & "\MoveRenderset.log"," Les frames " & $filename & " sont introuvables" & @CR & @CR & @CR)
    $yesno = MsgBox(4,"MoveRenderset","Les frames " & $filename & " sont introuvables." & @CR & "Voulez-vous voir la liste des TGA dans le dossier?")
    If $yesno = 7 Then
    Exit
Else 
    $tgadir = _FileListToArray($dirframes, "*.tga")
    _ArrayDisplay($tgadir, "MoveRenderset - Liste TGA de " & $episode & $scene)
EndIf
    
$selframes = ClipGet()
MsgBox(0, "Clipboard contains:", $selframes)

;I want to move the file that are listed in $selframes to $dirrenderset & "\*.tga"


;If FileExists(@ScriptDir & "\MoveRenderset.tmp") Then
;   FileDelete(@ScriptDir & "\MoveRenderset.tmp")
;   EndIf
;_FileCreate(@ScriptDir & "\MoveRenderset.tmp")



    
;    $yesno = MsgBox(4,"MoveRenderset","Voulez-vous déplacer tout les TGA de la liste précédente?")
;   If $yesno = 7 Then
;    Exit
;Else 
;   FileMove($dirframes & "\*.tga", $dirrenderset & "\*.tga")
;   $ArFrames = _FileListToArray($dirrenderset)
;EndIf
    
EndIf

$frames = _ArrayToString( $ArFrames,@TAB, 0, 0 )

_FileWriteLog(@ScriptDir & "\MoveRenderset.log","//-----------------------" & @CR & @CR & "Épisode: " & $episode & @CR & "Scène: " & $scene & @CR & "Version: " & $version & @CR & "Nb de frames: " & $frames  & @CR & @CR & "Déplacement terminé   -----------------------\\" & @CR & @CR & @CR)


MsgBox(0, "MoveRenderset", "Épisode: " & $episode & @CR & "Scène: " & $scene & @CR & "Version: " & $version & @CR & "Nb de frames: " & $frames  & @CR & @CR & "Déplacement terminé")

$defepisode = $episode

$defscene = $scene + 1

WEnd

Olivier.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

PHP has functions integrated for what you need to do.

Serialize and Unserialize

Serialize will flatten in an array into a string for storing session variables to mysql and whatnot.

http://us.php.net/serialize

Heres what you can do:

#include <Array.au3>

Dim $myArray[5] = ["Dog","Cat","Seabass","Gorilla","Tyrannosaurus"]

ClipPut (serialize($myArray))

$myNewArray = unserialize(ClipGet ())

_ArrayDisplay($myNewArray)

Func serialize($Array)
    Return _ArrayToString ( $Array, ",")
EndFunc

Func unserialize($String)
    $Array = StringSplit ( $String, ",")
    ;Strip off first element which contains number of items in array
    _ArrayDelete ( $Array, 0 )
    Return $Array
EndFunc
Edited by weaponx

Share this post


Link to post
Share on other sites

Ok lets see if we can make sense of this together. By the way la bienvenue à AutoIt et pardonnent mon français, laisse en fait la subsistance ceci en anglais!

Let me see if I've got this right, the following code presents the following Yes or No MsgBox: MoveRenderset the frames $filename are untraceable. Do you want to see the list of the TGA in the file?. A Yes response brings us to the _ArrayDisplay that you've been asking us about. And what you'd like to do is be able to select all or a few of the items listed in the array and have them moved to E:\Renderset\ with the extension .tga. Is that right?

If @Error=4 Then
        _FileWriteLog(@ScriptDir & "\MoveRenderset.log"," Les frames " & $filename & " sont introuvables" & @CR & @CR & @CR)
        $yesno = MsgBox(4,"MoveRenderset","Les frames " & $filename & " sont introuvables." & @CR & "Voulez-vous voir la liste des TGA dans le dossier?")
        If $yesno = 7 Then Exit
    Else 
        $tgadir = _FileListToArray($dirframes, "*.tga")
        _ArrayDisplay($tgadir, "MoveRenderset - Liste TGA de " & $episode & $scene)
    EndIf
    
    $selframes = ClipGet()
    MsgBox(0, "Clipboard contains:", $selframes)

    ;I want to move the file that are listed in $selframes to $dirrenderset & "\*.tga"
    If FileExists(@ScriptDir & "\MoveRenderset.tmp") Then
        FileDelete(@ScriptDir & "\MoveRenderset.tmp")
    EndIf
    _FileCreate(@ScriptDir & "\MoveRenderset.tmp")

Now a few things I'm confused about are if the file \MoveRenderset.tmp exists you what to delete the file and recreate an empty MoveRenderset.tmp file? And at the beginning of your last message you also said

What my script does is move certain files to a new directory based on information I input into some input box. The script find those files automatically based on the input I give. But if for some reason the script is not able to find the file I want. The script does a _FileListToArray to allow me to manually select the files I want to be moved. I'd like to be able to select some files from the _ArrayDisplay window, click on TextSelected, and when I click on the close button, I want the script to move those files. ...

Which I interperted as saying: you want to move certain files to a new directory -- have the script find those files -- if files do not exist then put those file names into an array and upon selecting and closing _ArrayDisplay have the script move those file names to the E:\Renderset\ or what exactly? If you can fill in some of the unknowns for me, I think we can get this working for you. Not using _ArrayDisplay, but a custom gui.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I tried TextSelected and it put it to the clipBoard like you said. But I need the selection to be in an array. Is there an easy way of doing this? I tried searching for ClipToArray or StringToArray but I couldnt find those functions.

Thanks,

Olivier.

hi,

If you want to go back to using -ArrayDisplay, this UDF might help put the clipboard back to an array for you to use for your other funcs;

; _ArrayDisplayclip.au3
#include-once
#include <Array.au3>
$asControls = StringSplit(WinGetClassList("", ""), @LF)
_ArrayDisplay($asControls, "Class List of Active Window")
_ArrayDisplay(_ClipBoardToArray(), "_ArrayDisplay() ClipBoard Array of Results")

Func _ClipBoardToArray()
    Local $ClipGet = ClipGet()
    If StringInStr($ClipGet, @LF) Then Local $ar_ClipBoard = StringSplit($ClipGet, @LF)
    If UBound($ar_ClipBoard) < 2 Then Return 0
    If StringReplace($ar_ClipBoard[1], "|", @LF) Then
        $i_extended=@extended
        Local $ar_Arrayclip2D[UBound($ar_ClipBoard) - 2 ][$i_extended ]
    EndIf
    For $a = 1 To UBound($ar_ClipBoard) - 2
        If StringInStr($ar_ClipBoard[$a], "|") Then
            Local $ar_ClipBoardRow = StringSplit($ar_ClipBoard[$a], "|")
            For $b = 2 To UBound($ar_ClipBoardRow) - 1
                ConsoleWrite("$ar_ClipBoardRow[$b]=" & $ar_ClipBoardRow[$b] & @LF)
                $ar_Arrayclip2D[$a - 1][$b - 2] = $ar_ClipBoardRow[$b]
            Next
        EndIf
    Next
    Return $ar_Arrayclip2D
EndFunc   ;==>_ClipBoardToArray
Best, randall Edited by randallc

Share this post


Link to post
Share on other sites

And what you'd like to do is be able to select all or a few of the items listed in the array and have them moved to E:\Renderset\ with the extension .tga. Is that right?

Yes, I want to move the files to E:\Renderset\SUBFOLDER. I already have a variable to fill the name of the subfolder.

Now a few things I'm confused about are if the file \MoveRenderset.tmp exists you what to delete the file and recreate an empty MoveRenderset.tmp file? And at the beginning of your last message you also said

You can forget all about MoveRenderset.tmp. As you can see those line are commented in the script. It is just a way I tried to make it work. I will delete those line, they are obsolete.

Which I interperted as saying: you want to move certain files to a new directory -- have the script find those files -- if files do not exist then put those file names into an array and upon selecting and closing _ArrayDisplay have the script move those file names to the E:\Renderset\ or what exactly? If you can fill in some of the unknowns for me, I think we can get this working for you. Not using _ArrayDisplay, but a custom gui.

Yes this is what I'm trying to do. For example I wan to move E:\usadata000\go_be\scene-011\frames\be011_007-0001.tga to E:\Renderset\be\be011_007\be011_007-0001.tga. Most of the times, my script will find the file I want to move and move them. But some times, some people make mistakes when they name the file. For example they could name the file be011_0070001.tga instead of be011_007-0001.tga. In those case I want to be able to inspect the file and make the decision to move certain of the file.

I hope I'm explaining myself clearly.

Thanks,

Olivier.

Share this post


Link to post
Share on other sites

Hey weaponx,

If I don't find a way to avoid using the clipboard, I'll give your method a try.

Thanks.

randallc I'm noob and I'm not sure what a UDF is. So I'll try to look up what that means, and I'll see.

Thanks.

Olivier

Share this post


Link to post
Share on other sites

Yes this is what I'm trying to do. For example I wan to move E:\usadata000\go_be\scene-011\frames\be011_007-0001.tga to E:\Renderset\be\be011_007\be011_007-0001.tga. Most of the times, my script will find the file I want to move and move them. But some times, some people make mistakes when they name the file. For example they could name the file be011_0070001.tga instead of be011_007-0001.tga. In those case I want to be able to inspect the file and make the decision to move certain of the file.

Yes this is helping to clear up the unknowns, however the following code doesn't make sense to me since whatever is entered into the $scene = InputBox could be "Scene Seven" or "Seven" or "7", right? Assuming most people will enter a number not a string of text, I'm wondering when $digit = 0 (false; $scene is not a digit) and $scene = StringRight($scene,4) would help your script? For example someone enters "Seven" for the episode resulting in $digit = 0 and StringRight("Seven",4) results in $scene = "even" which is not a digit. Just trying to follow the logic of the code, then again it could be my limited knowledge that's making me act a fool.

$scene = "00" & $scene  
    $digit = StringIsDigit($scene)
    If $digit = 1 Then
        $scene = StringRight($scene, 3)
    Else
        $scene = StringRight($scene, 4)
    EndIfoÝ÷ Ø­¶§³«Ê«²øªç¬¶*'êÞßÛ0«r¢éÞyÐ'tývX¤zÚ,k,"¶.µ)ãlr()àê'JÚâ^Li"èm¦åË
.Ù÷öØZ½ëa¢è!¶Ú.±ëaÀr¶°k,¨»ewvÚ©àzØ^¥«a¶¨º»Ú®&ëÖ¥²!jx)^
r¶bã(½èÜ(®K¢¼¨¸­µêí¡·¬i÷­©ì¢ºò®(!´Iã£+a̱û§jwa¢¢¶¥¥çZºÚ"µÍIÌÍÜÙ[[YÈHÛÙ]

BIÌÍØPÛHÝ[ÔYÑ^
    ÌÍÜÙ[[YË   ÌÎNÉÌLß
ÊIÌLÛÌÎNËÊBBWÐ^QÜ^J    ÌÍØPÛ
BQÜ    ÌÍÚHHÈPÝ[
    ÌÍØPÛJHLBBQ[PÛÜJ  ][ÝÑNÌLÝØY]L   ÌLÙÛ×ØIÌLÜØÙ[KLLIÌLÙ[YÉÌLÉ][ÝÈ  [È ÌÍØPÛÉÌÍÚWK ][ÝÑNÌLÔ[Ù]    ÌLØIÌLØLLWÌ
ÉÌLÉ][ÝÊBS^

Share this post


Link to post
Share on other sites

Yes this is helping to clear up the unknowns, however the following code doesn't make sense to me since whatever is entered into the $scene = InputBox could be "Scene Seven" or "Seven" or "7", right? Assuming most people will enter a number not a string of text, I'm wondering when $digit = 0 (false; $scene is not a digit) and $scene = StringRight($scene,4) would help your script? For example someone enters "Seven" for the episode resulting in $digit = 0 and StringRight("Seven",4) results in $scene = "even" which is not a digit. Just trying to follow the logic of the code, then again it could be my limited knowledge that's making me act a fool.

Yes, you are right about this. However, I will be the only one using this script, so I'll know to use a number and not a string.

Another question is why you're using _FileListToArray($dirscene) instead of FileExists($dirscene). Without setting _FileListToArray to a variable its not going to do you much good if $dirscene does exist. Likewise the $frames = _ArrayToString( $ArFrames,@TAB, 0, 0 ) seems odd since it is only setting $frames = $ArFrames[0] (the number of files in the directory listing creating the $ArFrames array. I would just use $ArFrames[0] if that's what you're after. Remember I'm new at this stuff too so I'm asking questions since we can all learn from one another wink.gif.

I did it this way because i'm new to this and didn't know better. I look at your suggestions and it make sense, so I'll probably update this part of my script.

But to answer your specific question here's what you need. And I'd like to say without SmOke_N schooling me on StringRegExp I probably wouldn't have thought to use this wink.gif. By the way, you'll need to change the path to your variables and also change FileCopy to FileMove if it works for you. Better to be safe than sorry, right? Enjoy, this was fun and hope it helped.

It seems to be a good Idea. I don't have time right now to update my script. I'm overloaded at work, so I'll probably have to wait until monday or tuesday to continue working on my script. I tried using the current version of my script and I found another bug. It's not returning the correct version of the scene :) .

So thank you, and I'll keep you updated once I have time to try your suggestions.

Olivier.

Share this post


Link to post
Share on other sites

I finally got to update my script and I was able to test it with an episode of 162 scenes. It now seems to work without bug, it's faster than ever, and the new functionality to select misnamed files works like a charm. I'm really happy right now. Thanks to everyone that helped me with this script.

Olivier.

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