Jump to content

Non-Variable Array Error -.- Require Help


 Share

Recommended Posts

Ok. Basically this script splits a word into characters, and adds $ infront of every letter to make it into a variable.

$open = FileOpen('C:\Documents and Settings\Owner\Desktop\wordlist\readmelist.txt', 0)
$file1 = FileReadLine($open, 1)
$file2 = FileReadLine($open, 2)
$file3 = FileReadLine($open, 3)
$file4 = FileReadLine($open, 4)
$file5 = FileReadLine($open, 5)
$file6 = FileReadLine($open, 6)
$file7 = FileReadLine($open, 7)
$file8 = FileReadLine($open, 8)
$file9 = FileReadLine($open, 9)
$file10 = FileReadLine($open, 10)
$split1 = StringSplit($file1, "")
$edit1[0] = StringReplace($split1[1], $split1[1], "{$}" & $split1[1])
$edit1[1] = StringReplace($split1[2], $split1[2], "{$}" & $split1[2])
$edit1[2] = StringReplace($split1[3], $split1[3], "{$}" & $split1[3])
$edit1[3] = StringReplace($split1[4], $split1[4], "{$}" & $split1[4])
$edit1[4] = StringReplace($split1[5], $split1[5], "{$}" & $split1[5])
$edit1[5] = StringReplace($split1[6], $split1[6], "{$}" & $split1[6])
Send($edit1)oÝ÷ Ùh­Øb²Ç+bëm+®º+ªê-x-=Ø:ºg§¶Æ§u'­¶)à³Ov;   Þ¯Ov
ë$¶t÷e¨®M=Ù«­¢+oßOv©i¨Z»}ýïEDÒ
MúyØ­Ö,²&åÊz-uç%j·ýÊÞj×ÉëtߧÝt

That works, But it doesn't have Arrays, it merely sends the last split, abcdef, it sends $f.

I need it to be an array, but it doesn't seem to be working out for me:'(, thanks for the help - Jasio

Edited by Jasio
Link to comment
Share on other sites

  • Moderators

It doesn't look right what your doing, but looking at your code I've tried to duplicate what your trying to do:

$File = @DesktopDir & '\wordlist\readmelist.txt'
For $iCount = 1 To 10
    $aSplit = StringSplit(FileReadLine($File, $i), '')
    For $xCount = 1 To $aSplit[0]
        $edit1 &= StringReplace($aSplit[$xCount], $aSplit[$xCount], '$' & $aSplit[$xCount])
    Next
Next
Send($edit1)

Edited by SmOke_N

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 making a word descrambler. using checksums on each word (giving a-z a prime number) and multiplying them. So if you had word, and drow, they will have the same value, which will thus send Word as your answer. So i need $edit1[0] to be the first character with $ infront of it, basically, then having $edit1[0] * $edit[1] etc, to find the checksum :whistle: ty

Link to comment
Share on other sites

  • Moderators

I'm making a word descrambler. using checksums on each word (giving a-z a prime number) and multiplying them. So if you had word, and drow, they will have the same value, which will thus send Word as your answer. So i need $edit1[0] to be the first character with $ infront of it, basically, then having $edit1[0] * $edit[1] etc, to find the checksum :) ty

:whistle::)

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

Eh.. It takes words like hasoles and turns it into asshole.. by checking the number.. asshole = 1203947123, because a times s times s, etc. = that. So if you take s times a times s, it has the same value. =/?

Do you have any instant messaging programs.. to make this easier -.-

Edited by Jasio
Link to comment
Share on other sites

I'm making a word descrambler. using checksums on each word (giving a-z a prime number) and multiplying them. So if you had word, and drow, they will have the same value, which will thus send Word as your answer. So i need $edit1[0] to be the first character with $ infront of it, basically, then having $edit1[0] * $edit[1] etc, to find the checksum :whistle: ty

So, you need an array of the first 26 primes greater than one. Then to checksum the word, derive the array index for the prime from the ascii code for the char:

$aPrimes = StringSplit("2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101", " ")

While 1
     $sWord = InputBox("Word checksumer", "Enter word to checksum:  ", "")
     If @error Then Exit
     $iChkSum = _ChkSumWord($sWord)
     MsgBox(64, "Results", "The word " & $sWord & " has a checksum of " & $iChkSum)
Wend

; Function to checksum word
Func _ChkSumWord($sInput)
     Local $c, $iReturn = 1
     Local $aSplit = StringSplit($sInput, "")
     For $c = 1 To $aSplit[0]
          Local $iAscii = Asc($aSplit[$c])
          If $iAscii > 90 Then $iAscii = $iAscii - 32 ; To ignore case
          $iAscii = $aPrimes[$iAscii - 64] ; indexes a=1, z=26
          $iReturn = $iReturn * $iAscii
     Next
     Return $iReturn
EndFunc

Non-alphabetic characters, spaces, numbers, hyphens, etc. might blow up that function so you can add some sanity checking. This is only an example of your word checksum technique, the file reading and whatever you were Send()'ing to was left out for the demo.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'm not sure if people are understanding my issue. I'm merely getting the errors mentioned in my topic post. I have a script written, it doesn't need any real editing. I just need to know why I can't make $edit1 an array, how to Declare it before making it into an array. I know how to do the checksum, i was merely explaining it so that people understand what the script does.

Link to comment
Share on other sites

I'm not sure if people are understanding my issue. I'm merely getting the errors mentioned in my topic post. I have a script written, it doesn't need any real editing. I just need to know why I can't make $edit1 an array, how to Declare it before making it into an array. I know how to do the checksum, i was merely explaining it so that people understand what the script does.

Did you read the helpfile on arrays? :whistle:

Making $edit1 and array, without changing anything else...

Dim $edit1[6]
$edit1[0] = StringReplace($split1[1], $split1[1], "{$}" & $split1[1])
$edit1[1] = StringReplace($split1[2], $split1[2], "{$}" & $split1[2])
$edit1[2] = StringReplace($split1[3], $split1[3], "{$}" & $split1[3])
$edit1[3] = StringReplace($split1[4], $split1[4], "{$}" & $split1[4])
$edit1[4] = StringReplace($split1[5], $split1[5], "{$}" & $split1[5])
$edit1[5] = StringReplace($split1[6], $split1[6], "{$}" & $split1[6])

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Did you read the helpfile on arrays? :whistle:

Making $edit1 and array, without changing anything else...

Dim $edit1[6]
$edit1[0] = StringReplace($split1[1], $split1[1], "{$}" & $split1[1])
$edit1[1] = StringReplace($split1[2], $split1[2], "{$}" & $split1[2])
$edit1[2] = StringReplace($split1[3], $split1[3], "{$}" & $split1[3])
$edit1[3] = StringReplace($split1[4], $split1[4], "{$}" & $split1[4])
$edit1[4] = StringReplace($split1[5], $split1[5], "{$}" & $split1[5])
$edit1[5] = StringReplace($split1[6], $split1[6], "{$}" & $split1[6])

:)

Thanks <3, i searched the Helpfile for arrays, all i kept getting were different things you could do to an array :)..
Link to comment
Share on other sites

Another question: Lets say i have 12 total arrays for $edit1. What if $edit1[0-6] have a value, but the rest do not. I get an error: ==> Array variable has incorrect number of subscripts or subscript dimension range. So how do i make all the empty fields not count?

Link to comment
Share on other sites

Another question: Lets say i have 12 total arrays for $edit1. What if $edit1[0-6] have a value, but the rest do not. I get an error: ==> Array variable has incorrect number of subscripts or subscript dimension range. So how do i make all the empty fields not count?

A one-dimentional array is just a list of items numbered 0 thru n. When you create the array, you specify how long the list is (though it can be changed later). In my example $edit1 is declared by the Dim command as a list of six items (numbered 0 thru 5).

If you know you will have 10 things in your list, just declare:

Dim $edit1[10] ; Items are $edit1[0] thru $edit1[9]oÝ÷ Øò¢è§r[zØ^jºÚÉ«·P1méò¢ç붮®

You could just do Dim again, but that erases the data in the array. ReDim can change the size without data loss in the remaining array.

Hope that helps... :whistle:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thats not what i was asking.. -.-.. What im saying is, lets say the person enters 'eoinsdf', in my Input box, you see, i have it set up to take 17 total characters (or.. whatever).. So, the person has only entered 7, now since the other 10 variables dont have a value, i get the array not specified or declared whatever error.. I need to know how to make blanks into nothing.. or have it count blanks and remove the variable :whistle:

Link to comment
Share on other sites

Thats not what i was asking.. -.-.. What im saying is, lets say the person enters 'eoinsdf', in my Input box, you see, i have it set up to take 17 total characters (or.. whatever).. So, the person has only entered 7, now since the other 10 variables dont have a value, i get the array not specified or declared whatever error.. I need to know how to make blanks into nothing.. or have it count blanks and remove the variable :whistle:

Why not use a stringlen and then append a char that will not be used during your program for the remaining characters - in your example : eoinsdf would turn into eoinsdf??????????

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Thats not what i was asking.. -.-.. What im saying is, lets say the person enters 'eoinsdf', in my Input box, you see, i have it set up to take 17 total characters (or.. whatever).. So, the person has only entered 7, now since the other 10 variables dont have a value, i get the array not specified or declared whatever error.. I need to know how to make blanks into nothing.. or have it count blanks and remove the variable :whistle:

If you use StringSplit() to break the word into an array, it already has the required size, plus one for the count in index 0. For example:

$Split1 = StringSplit("Cat", "")
$Split2 = StringSplit("Elephant", "")oÝ÷ Ù¬º[l{ayú%"(קµú+¶®¶²³MúJb·]oÝ÷ Øò¢ë!¢é]ç¶+y«^i×b¶*'jV«­¬¬¡ûazƦzȳz붢éíx§uìt~º&¶¶¸§*eÖ®¶­sdFÒb33c¶VFC²b33cµ7ÆC³ÒÒ²vWG2ÆVæwFöbBF'R2¤FÒb33c¶VFC%²b33cµ7ÆC%³ÒÒ²vWG2ÆVæwFöbF'R

You may have noticed that the demo I posted in message #7 of this thread is not limited to a certain word length.

Hope that helps... :)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...