Jump to content

while loop


rkr
 Share

Recommended Posts

  • Developers

Please pay attention to the forum purpose when posting threads:

Quote

Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moved to support.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You should be modifying the text file directly and not trying to automate Notepad.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

@rkr it would be helpful if you explained just what you are trying to do, and what your expected outcome is - it may be clear to you, but not necessarily to others just from looking at your code. Also, there is bound to be a better way to do this if you share exactly what you are trying to accomplish. For example, just looking at the code, you can convert all of this:

run("notepad","",@SW_MAXIMIZE)
winwaitactive("Untitled - Notepad")
send("!F")
send("o")
winwaitactive("Open")
send($file_location)
Send("{ENTER}")
Send($file_name)
Send("{ENTER}")
WinWaitActive("GMS Det Leg.txt - Notepad")

To this:

ShellExecute("Notepad.exe", $file_location & $file_name)

We are happy to assist further, if you explain what you are trying to do in more detail. I am going to posit that your best bet will be reading the file into an array, and then changing the values accordingly. More information from you will help us help you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

8 hours ago, JLogan3o13 said:

@rkr it would be helpful if you explained just what you are trying to do, and what your expected outcome is - it may be clear to you, but not necessarily to others just from looking at your code. Also, there is bound to be a better way to do this if you share exactly what you are trying to accomplish. For example, just looking at the code, you can convert all of this:

run("notepad","",@SW_MAXIMIZE)
winwaitactive("Untitled - Notepad")
send("!F")
send("o")
winwaitactive("Open")
send($file_location)
Send("{ENTER}")
Send($file_name)
Send("{ENTER}")
WinWaitActive("GMS Det Leg.txt - Notepad")

To this:

ShellExecute("Notepad.exe", $file_location & $file_name)

We are happy to assist further, if you explain what you are trying to do in more detail. I am going to posit that your best bet will be reading the file into an array, and then changing the values accordingly. More information from you will help us help you.

i will try to explain it here in detail..

if you open the text file 'GMS Det Leg.txt'- it has 2 lines -> LOADCN   P   1.166  &      LOADCN   R   1.166  .. the autoit pgrm should open the notepad replace the numerals 1.166 based on an equation (here, just increase by 1 and 1.5 respectively for each lines) and the notepad is to be saved/closed. this should repeat till the top line become LOADCN   P   9.166 .. i believe my intention is clear... thanks for all suggestion  
   

Link to comment
Share on other sites

You're still ignoring the best advice, already given here

Now, no your intend is unclear: as you repeatedly increment the same values in the same file, you could as well replace once by the final values (resp. 9.166 and 13.166). That, or save to distinct files at every step in your loop.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

If i was you, seeing that you really want to go that way, changing the file, i also wouldn't open the file with notepad, instead i would use

_ReplaceStringInFile

If those are the only 2 lines in it, it's even easier, you don't need to read the file, simply overwrite the same lines as you want, with that function.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

×
×
  • Create New...