Jump to content

$variable problem :(


Recommended Posts

Hi All,

My brain is fried over this little issue... I've got this gem of a piece of code that I've been tryin' to alter to fit my needs. With lots 'o help from the guys here on the forums I've just about got it licked, however now this pops up. I change the value of a $var and the script won't find the files that match that $var. If I leave the $var alone, it finds the files just fine. Here's what I've got...

$word_search = GUICtrlCreateInput(".au3", 30, 130, 200, 20)

I'm tryin to find .txt files... if I leave the varibale set to .au3, it finds the .txt files just fine, if I change it to .txt - NO FILES FOUND. :o

Anyone have a suggestion?

Thanks in advance.

BBB

Link to comment
Share on other sites

Sorry, I should have posted more. I was tryin' to narrow it down abit. The problen is somewhere in this bit of code:

#include <GuiConstants.au3>

GUICreate("", 400, 400)
$defaultpath = ("C:\Data collector")
$location = GUICtrlCreateInput($defaultpath, 30, 100, 200, 20, $ES_READONLY)

$browse_btn = GUICtrlCreateButton("Browse Folders", 260, 100, 110, 20); Browse Button


$filext = (".au3"); Change This to .txt script fails to find .txt files - leave it alone it works.


$Fextension = GUICtrlCreateInput($filext, 30, 130, 200, 20)
$go_btn = GUICtrlCreateButton("Start Search", 260, 130, 110, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$Edit1 = GUICtrlCreateList("Found File list", 30, 170, 340, 100)
$label = GUICtrlCreateLabel("Files Found with Phrase: None", 205, 330, 220, 20)
$label2 = GUICtrlCreateLabel("Searched Files: None", 30, 330, 120, 20)
$view_btn = GUICtrlCreateButton("View File", 185, 350, 80, 20)
$Search_btn = GUICtrlCreateButton("View All", 40, 350, 80, 20)
$SciTE_btn = GUICtrlCreateButton("Open in SciTE", 285, 350, 80, 20)

    $Found = 0
    $Searched = 0
    GUICtrlSetData($label, "Files Found with Phrase: " & $Found)
    GUICtrlSetData($Edit1, "")
    $Temp_Dir = (GUICtrlRead($location))

If $Temp_Dir = "" Then $Temp_Dir = $defaultpath
    If StringRight($Temp_Dir, 1) <> "\" Then $Temp_Dir = $Temp_Dir & "\"

    $Temp_File = "*.txt"
    $Temp_Word = (GUICtrlRead($Fextension))
    RunWait(@ComSpec & ' /c ' & 'dir "' & $Temp_Dir & $Temp_File & '" /a :h /b /s' & ' > "' & @TempDir & '\txt.txt"', '', 

@SW_HIDE)
    $hFile = FileOpen(@TempDir & "\txt.txt", 0)
    While 1
        $sLine = FileReadLine($hFile)
        If @error = -1 Then ExitLoop
        $Temp_Dir = $sLine
        $Temp_Search = FileRead($sLine, FileGetSize($sLine))
        If StringInStr($Temp_Search, $Temp_Word) Then
            GUICtrlSetData($Edit1, $sLine, 1)
            $Found = $Found + 1
            GUICtrlSetData($label, "Files Found with Phrase: " & $Found)
        EndIf
        $Searched = $Searched + 1
        GUICtrlSetData($label2, "Searched Files: " & $Searched)
    WEnd


GUISetState()

$Temp_Dir1 = $Temp_Dir
$Temp_Dir1 = StringSplit($Temp_Dir1,"\")
$filename = $Temp_Dir1[$Temp_Dir1[0]]
    If $Found = 0 Then 
        MsgBox(48, "ERROR!", "No Files Found.")
ElseIf $Found = 1 Then
    $sAnswer = MsgBox(32+3,"File Found!",$filename & "   Is this your file?   ")
        IF $sAnswer = 6 Then
                        
        ElseIf $sAnswer = 7 Then
            
        ElseIf $sAnswer = 2 Then
            Exit
        EndIf

ElseIf $Found > 1 Then
    MsgBox(48, "More Than One File Found!", "Please Your Choose Your File.")
    EndIf

;-- problem above somewhere

I'm not a programmer and I've just begun trying to play with scripting. I just don't see the problem.

Any Help would be greatly appreciated.

Thanks.

BBB

Link to comment
Share on other sites

Thanks Valuater,

I can look at the script, it looks great, just the thing I need... but, uhmmm, "Autoit Error Reading the file: GuiList.au3". Was this created with the beta of v3? Or am I missing part of v3. As I mentioned I'm quite new to scripting and don't really have a clue as to what guilist.au3 is or goes... :o I'll have a go at seeing if I can get it to run...

Thanks again!

BBB

Link to comment
Share on other sites

Thanks Valuater,

I can look at the script, it looks great, just the thing I need... but, uhmmm, "Autoit Error Reading the file: GuiList.au3". Was this created with the beta of v3? Or am I missing part of v3. As I mentioned I'm quite new to scripting and don't really have a clue as to what guilist.au3 is or goes... :o I'll have a go at seeing if I can get it to run...

Thanks again!

BBB

honestly... because you have seen those two scripts AND you are new AND you want beta AND SciTE

see this... it will help you ALOT!!!

http://www.autoitscript.com/forum/index.php?showtopic=21048#

8)

NEWHeader1.png

Link to comment
Share on other sites

Valuater,

Thanks, I've seen that tut... didn't help much. I've found that these types of tut's are for those the have an abundant amount of time to "fiddle" with code, in between rubbing Aspercreme, BenGay, etc., on their aching noggins, and guzzling massive amounts of Red Bull into the wee hours. I've come here in hopes that someone such as yourself (or other knowledgeable mentors) would find pleasure or some type of self gratification in helping those that are less experienced. Instead I've recieved (with some exception) broken or damaged code (only thing missing is the annoying "HA HA" audio loop upon execution) and little in the way of helpful guidance. Seems to me the only ones that truly benefit from these forums are those that really don't need them (the experiened scripters that are here to "show off" their work). Perhaps I sound harsh, perhaps I'm correct in my observations. I was given a task to attempt to "automate" a somewhat tedious operation, instead I've recieved mind-numbing misdirection the likes that would do any sleight of hand artist proud. Thank you for the smoke and mirrors, I've had my fill.

Good evening.

BBB

Link to comment
Share on other sites

Valuater,

Thanks, I've seen that tut... didn't help much. I've found that these types of tut's are for those the have an abundant amount of time to "fiddle" with code, in between rubbing Aspercreme, BenGay, etc., on their aching noggins, and guzzling massive amounts of Red Bull into the wee hours. I've come here in hopes that someone such as yourself (or other knowledgeable mentors) would find pleasure or some type of self gratification in helping those that are less experienced. Instead I've recieved (with some exception) broken or damaged code (only thing missing is the annoying "HA HA" audio loop upon execution) and little in the way of helpful guidance. Seems to me the only ones that truly benefit from these forums are those that really don't need them (the experiened scripters that are here to "show off" their work). Perhaps I sound harsh, perhaps I'm correct in my observations. I was given a task to attempt to "automate" a somewhat tedious operation, instead I've recieved mind-numbing misdirection the likes that would do any sleight of hand artist proud. Thank you for the smoke and mirrors, I've had my fill.

Good evening.

BBB

Your welcome...

obviopusly you havent seen many of my post or how many people i have helped here in Autoit, however there are some who wish us to write the entire script for them. I have even gone to the extreme to write a script completely in Autoit that one only need click, watch and listen... but thats not good enough.

The script you demolished was mine infact. so, TO HELP YOU FURTHER, i showed you the advanced version that included searching for different types of files like you were after...

I've come here in hopes that someone such as yourself (or other knowledgeable mentors) would find pleasure or some type of self gratification in helping those that are less experienced.

on that... you are exactly correct, i love Autoit and enjoy helping others

I have seen posts by other "helpers" here who say, maybe Valuater will write it for you. They, and most times I, prefer to guide newbies and help them learn, not do everything for them.

and you call all of that that smoke and mirrors....

obviously, your observation is incorrect!

I wish you luck at finding other scripting languages out there that are as easy as Autoit to understand, as powerful as Autoit is, as helpful in the forums as Autoit forums are and as cost effective as Autoit.... Free!

Valuater

8)

NEWHeader1.png

Link to comment
Share on other sites

Valuater,

No infact I have seen many of your posts, and yes, I do believe that you believe you may be assisting those in need. I do not fantasize about the fact that the last script that YOU PROVIDED ME (without my asking), is in fact either flawed, or I do not have the required software to execute it. It fails to execute on my system, upon execution "Autoit Error Reading the file GuiList.au3" (as my previous post).

Your Code

I simply asked if I needed additional modules (ie:GuiList.au3), or how to correct this issue. YOU became defensive and assumed that I was some type of code thief.

The script you demolished was mine infact. so, TO HELP YOU FURTHER, i showed you the advanced version that included searching for different types of files like you were after...

I NEVER asked you or anyone else for code. YOU OFFERED AND PROVIDED the code. Accepting what was offered does not make one a thief. I am not interested in "stealing" ones code. I am interested in guidance in writting code. We can "Flame" each other untill the end of time, that will neither help nor satisfy me, I would wish you the same. If you are truly as you say, simply provide me the direction that an inexperienced noob requires to accomplish a given task, or do not reply to my posts. By all means DO NOT provide me code that does not work, or needs endless research to correct, I do not have the ability. Please keep in mind that EVERYONE starts out or has started out a noob, even you, and reading the "Help" file doesn't alway answer the question.

Regards,

BBB

Link to comment
Share on other sites

Fine... i can live with that...

just remmber i never said you stole anything, i was only saying that it was something else that i gave to the community..

you are welcome to any script i have posted here and i hope they can help you.

about the include file, you should be able to comment it out like this

;#Include <GuiList.au3>

i tested it on my computer and it worked

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Fine... i can live with that...

just remmber i never said you stole anything, i was only saying that it was something else that i gave to the community..

you are welcome to any script i have posted here and i hope they can help you.

about the include file, you should be able to comment it out like this

;#Include <GuiList.au3>

i tested it on my computer and it worked

8)

And to think, that someone would even think you weren't there to 'help' guide in the right direction, even through flamming you still give the answer he needed. I've said it before and I'll say it again... you're a better man than I... words I would never say in front of my kids would have been said for sure.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm sure you can, and I'm no idiot (some including yourself may disagree), I've tried that and I got this:

Line 136 (File"C:\NEW SEARCH\Valuater_Code.au3")
$FileList =_FileListToArray($Temp_Dir,$Temp_File, 1)
$FileList =^ERROR

Error:Unknown Functtion name.:

Hence the comment about broken code. Perhaps it's on my end. However I've not seen GuiList.au3 in any other scripts and am unfimiliar with it's function. Again for the (how many times have I posted now?) I'm not a programmer, I'm a Land Surveyor. If this code works for everyone else, then I DO apologize. Seems strange though, only code that I get from you has issues... That's why I asked what ver. of Autoit was used. Some earlier code doesn't work for me. I've got the latest ver., AutoIt v3.1.1 released (7th Apr, 2005).

BBB

Link to comment
Share on other sites

I'm sure you can, and I'm no idiot (some including yourself may disagree), I've tried that and I got this:

Line 136 (File"C:\NEW SEARCH\Valuater_Code.au3")
$FileList =_FileListToArray($Temp_Dir,$Temp_File, 1)
$FileList =^ERROR

Error:Unknown Functtion name.:

Hence the comment about broken code. Perhaps it's on my end. However I've not seen GuiList.au3 in any other scripts and am unfimiliar with it's function. Again for the (how many times have I posted now?) I'm not a programmer, I'm a Land Surveyor. If this code works for everyone else, then I DO apologize. Seems strange though, only code that I get from you has issues... That's why I asked what ver. of Autoit was used. Some earlier code doesn't work for me. I've got the latest ver., AutoIt v3.1.1 released (7th Apr, 2005).

BBB

thats why i posted the tut

it has the beta button "Get Beta Version"... you really need that for most of the code posted here, because

1

it is stable

2

it has many, many additional features

8)

NEWHeader1.png

Link to comment
Share on other sites

Valuater,

Ok, I'd like to startoff fresh... (if it's acceptable to you, if not I understand). Getting back to the very first post in this thread...

Hi All,

My brain is fried over this little issue... I've got this gem of a piece of code that I've been tryin' to alter to fit my needs. With lots 'o help from the guys here on the forums I've just about got it licked, however now this pops up. I change the value of a $var and the script won't find the files that match that $var. If I leave the $var alone, it finds the files just fine. Here's what I've got...

CODE

$word_search = GUICtrlCreateInput(".au3", 30, 130, 200, 20)

I'm tryin to find .txt files... if I leave the varibale set to .au3, it finds the .txt files just fine, if I change it to .txt - NO FILES FOUND. blink.gif

Anyone have a suggestion?

Thanks in advance.

BBB

Please note "gem" of a piece of code...

Can you help me understand... or... would you help me understand why this is? Forget that I "Butchered" your code. Why doesn't that $var doesn't work right?

I hopethat you will or can explain...

BBB

Link to comment
Share on other sites

this worked for the search of .txt

#include <GuiConstants.au3>

GUICreate("", 400, 400)
$defaultpath = ("C:\temp")
$location = GUICtrlCreateInput($defaultpath, 30, 100, 200, 20, $ES_READONLY)

$browse_btn = GUICtrlCreateButton("Browse Folders", 260, 100, 110, 20); Browse Button


$filext = (".txt"); Change This to .txt script fails to find .txt files - leave it alone it works.


$Fextension = GUICtrlCreateInput($filext, 30, 130, 200, 20)
$go_btn = GUICtrlCreateButton("Start Search", 260, 130, 110, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$Edit1 = GUICtrlCreateList("Found File list", 30, 170, 340, 100)
$label = GUICtrlCreateLabel("Files Found with Phrase: None", 205, 330, 220, 20)
$label2 = GUICtrlCreateLabel("Searched Files: None", 30, 330, 120, 20)
$view_btn = GUICtrlCreateButton("View File", 185, 350, 80, 20)
$Search_btn = GUICtrlCreateButton("View All", 40, 350, 80, 20)
$SciTE_btn = GUICtrlCreateButton("Open in SciTE", 285, 350, 80, 20)

    $Found = 0
    $Searched = 0
    GUICtrlSetData($label, "Files Found with Phrase: " & $Found)
    GUICtrlSetData($Edit1, "")
    $Temp_Dir = (GUICtrlRead($location))

    If $Temp_Dir = "" Then $Temp_Dir = $defaultpath
    If StringRight($Temp_Dir, 1) <> "\" Then $Temp_Dir = $Temp_Dir & "\"

    $Temp_File = "*.txt"; ***************** it works ****** this is where it searches from .txt, .au3 or ???
    $Temp_Word = (GUICtrlRead($Fextension))
    RunWait(@ComSpec & ' /c ' & 'dir "' & $Temp_Dir & $Temp_File & '" /a :h /b /s' & ' > "' & @TempDir & '\txt.txt"', '', @SW_HIDE)

    $hFile = FileOpen(@TempDir & "\txt.txt", 0)
    While 1
        $sLine = FileReadLine($hFile)
        If @error = -1 Then ExitLoop
        $Temp_Dir = $sLine
        $Temp_Search = FileRead($sLine, FileGetSize($sLine))
        If StringInStr($Temp_Search, $Temp_Word) Then
            GUICtrlSetData($Edit1, $sLine, 1)
            $Found = $Found + 1
            GUICtrlSetData($label, "Files Found with Phrase: " & $Found)
        EndIf
        $Searched = $Searched + 1
        GUICtrlSetData($label2, "Searched Files: " & $Searched)
    WEnd


GUISetState()

    

$Temp_Dir1 = $Temp_Dir
$Temp_Dir1 = StringSplit($Temp_Dir1,"\")
$filename = $Temp_Dir1[$Temp_Dir1[0]]
    If $Found = 0 Then
        MsgBox(48, "ERROR!", "No Files Found.")
ElseIf $Found = 1 Then
    $sAnswer = MsgBox(32+3,"File Found!",$filename & "   Is this your file?   ")
        IF $sAnswer = 6 Then
                        
        ElseIf $sAnswer = 7 Then
            
        ElseIf $sAnswer = 2 Then
            Exit
        EndIf

ElseIf $Found > 1 Then
    MsgBox(48, "More Than One File Found!", "Please Your Choose Your File.")
    EndIf

while 1
    sleep(10)
WEnd

your script at the lower part is ok... none of the buttons work on the upper part

8)

NEWHeader1.png

Link to comment
Share on other sites

Valuater,

Thanks for lookin' at this... I really didn't want you to fix it, but explain it to me. That's why I posted in the first place. I tried lots o' things (that's how I butchered up your script to begin with) to get this to work for me. (I was pretty handy with "batch" in the 'ol days... 1200 line autoexec.bat... ofcourse it took my machine 3 days to boot) Everything was good untill I changed that $var... then (poof) no longer working. What is that $var purpose? If not a file search criteria? I stumped...

$word_search = GUICtrlCreateInput(".au3", 30, 130, 200, 20)

And do I need to install the Beta, I mean really (Autoit Beta I mean)... I always thought Beta was "Danger Will Robinson, Danger!"

And as far as the lower portion of the script... I think Oxin8 (I hope that's right) suggested that. Again, I'm No Programmer, I'm A Land Surveyor... Just tryin' to automate some tasks that our field guys may find difficult. (Computer to them means video game)

your script at the lower part is ok... none of the buttons work on the upper part

BTW, none of this is mine, I just modified pieces...

Land Surveyor....

Thanks Again,

BBB

PS, Valuater... sorry for the flame. Just Frustrated.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...