Jump to content

extremely simple script giving me fits!


Recommended Posts

#include<file.au3>
dim $file
_FileReadToArray("menu.txt",$file)
filecopy($cmdlineraw, "C:\program files\road runner\skins\renesis v2\backgrounds")
$strsplit= StringSplit($cmdlineraw, "\")
$count=$strsplit[0]
$last= $strsplit[$count]
msgbox(0,"test", $last)
msgbox(0,"test",$file[21])
$file[21]=$last

_FileWriteFromArray("menu.txt", $content,1)

I've been working on this script for about a day now and i have no idea why i'm gettin errors. Basically i'm reading a text file to an array then later outputing to the same text file. My problem is with the array. I've declared it.. it reads to without any errors, but later when i try to display the results of the array ($file[21] in this case) the script errors out telling me that $file isnt declared an array. I have several other scripts using nearly the exact same code and they work flawlessly. What gives?

Link to comment
Share on other sites

You are using variables:

MsgBox(0, "", $cookie)oÝ÷ Ùµ¢¶.·öß»-"x§ö¥¹ë-¢Ø^«­¢+ØÀÌØí½½­¥ôÅÕ½ÐíÑáÐÅÕ½Ðì¤oÝ÷ Ø[¥Ç+p¢é]m觶¬q«jëh×6$cookie = "text"
MsgBox(0, "", $cookie)
which variables arent defined prior to use?
Link to comment
Share on other sites

  • Moderators

Well we could go down the list.

1. You are using "menu.txt", the interpreter assumes that this file is in the same directory as the script, is this so?

2. FileCopy()... you may want to include a backslash after backgrounds if you are just trying to copy the file that $cmdlineraw gives you to that directory.

3. _PathSplit() will give you the file name if you want to look at that solution.

4. Put an #include <array.au3> at the top of your script, and after this line msgbox(0,"test", $last) Put

_ArrayDisplay($file, 'Array Content')
to be sure there are 21 elements.

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

Well we could go down the list.

1. You are using "menu.txt", the interpreter assumes that this file is in the same directory as the script, is this so?

2. FileCopy()... you may want to include a backslash after backgrounds if you are just trying to copy the file that $cmdlineraw gives you to that directory.

3. _PathSplit() will give you the file name if you want to look at that solution.

4. Put an #include <array.au3> at the top of your script, and after this line msgbox(0,"test", $last) Put

_ArrayDisplay($file, 'Array Content')
to be sure there are 21 elements.

1. Yes

2. Done.. but oddly it was working without it too

3. Will look into that.. but it already copies the file correctly. Still might save some processing cycles tho

4. Done. Makes no difference though. Array display does nothing and the script still errors to the "subscript" error.

this is the other script i am using that uses the same concept. Works without any errors:

#include<file.au3>
;msgbox(0,"color",$cmdlineraw)
dim $content
_FileReadToArray("menu.txt",$content)
if $cmdlineraw="Midnight" Then
    $content[23]="&BackgroundColor=Midnight&"
elseif $cmdlineraw="Crimson" Then
    $content[23]="&BackgroundColor=Crimson&"
elseif $cmdlineraw="Lemans" Then
    $content[23]="&BackgroundColor=Lemans&"
elseif $cmdlineraw="Sapphire" Then
    $content[23]="&BackgroundColor=Sapphire&"
elseif $cmdlineraw="Emerald" Then
    $content[23]="&BackgroundColor=Emerald&"
endif
_FileWriteFromArray("menu.txt", $content,1)

See.. same concept, using the same file in the same directory. One works one doesnt :whistle:

Link to comment
Share on other sites

$content

oops thats an error on my part. $content was the first variable name i tried then i later changed it to $file. I guess since my script never gets down to that last line i didnt notice $content was still there. Good find (still need a solution to the original question though).

Edited by sonicxtacy02
Link to comment
Share on other sites

  • Moderators

You really aren't giving us much to go on to give a solution. You say you have one script that is doing it ok, and the other that isn't but they are the same :whistle:

My last attempt to help (because I have no way of testing anything you've provided) is... Are you sure the file isn't already open and being used by something else?

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

You really aren't giving us much to go on to give a solution. You say you have one script that is doing it ok, and the other that isn't but they are the same :whistle:

My last attempt to help (because I have no way of testing anything you've provided) is... Are you sure the file isn't already open and being used by something else?

well i didnt think that was the case considering all the similar scripts use the same file without any flaws... but all be damned.. u were right. Gonna work around that issue. Thanks as always smoke.

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...