damyo Posted May 11, 2005 Posted May 11, 2005 (edited) Hello, I am new to the forums aswell as autoit itself. I have a question that if answered will make me very grateful to you. So in spite of me coming off as annoyin here i go....Can someone please tell me how I would go about making a script that. 1.selects a random line from txt file 2.typing out the selected line Ive managed to get line for line and have it open a msgbox but I haven't managed to get the line to be random aswell as having it typed out and entered. if answered thank you so much! If not well poo on you. Edited May 11, 2005 by damyo
kjactive Posted May 11, 2005 Posted May 11, 2005 (edited) Well that was a basic one: Global Const $File = 'File path & name' : the & char is a 'put together' char $ID = FileOpen($File,0) ;open the file $a = 0 While 1 $a = $a + 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If Random(1,100) = $a then MsgBox(0, "Line read:", $line) ConsoleWrite( "Line read:" & $line & @CRLF) Endif Wend FileClose($ID) EndIf This is somewhat strange but there is hundred ways to do this - but as example okay, this is real random as this get recounted at every line he!!!... kjactive Edited May 11, 2005 by kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc...
herewasplato Posted May 11, 2005 Posted May 11, 2005 (edited) Hello, I am new to the forums aswell as autoit itself. I have a question that if answered will make me very grateful to you. So in spite of me coming off as annoyin here i go....Can someone please tell me how I would go about making a script that. 1.selects a random line from txt file2.typing out the selected lineIve managed to get line for line and have it open a msgbox but I haven't managed to get the line to be random aswell as having it typed out and entered. if answered thank you so much! If not well poo on you.<{POST_SNAPBACK}>so you already have the code to open the file for read...so , I'll skip that and offer this sparse set of hints as yet another way:$N_lines = _FileCountLines( $sFilePath )$N_Rand = Random(1,$N_lines,1 )$S_Rand_Line_From_File = FileReadLine ( filehandle or "filename" ,$N_Rand)Add you own error checking.....The above is untested code - let me know if it was anywhere near right.edit: typo Edited May 23, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now