Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7717081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:47:43+00:00 2026-06-01T02:47:43+00:00

well i am currently writing a script that is meant to check the logs

  • 0

well i am currently writing a script that is meant to check the logs of another script i wrote to see if it has had three or more unsuccessful pings in a row before a successful one, this is just barebones at the moment but it should look something like this

fileread,x,C:\Users\Michael\Desktop\ping.txt
result:=RegExMatch(%x% ,failure success)
msgbox,,, The file is = %x% `n the result is  = %result%

now the file that is trying to read is

success failure success

and for some reason, when it reads the file it says that the variable %x% ‘contains illegal characters

  • when i copy and paste the contents of ping.txt into the script and save it as a variable it works
  • i have made sure that the file has windows line endings CR +LF
  • i have assigned the variable generated in file read as another variable thus stripping any trailing or leading whitespace characters
  • the file is encoded in ANSI and still has the problem with UTF8
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:47:44+00:00Added an answer on June 1, 2026 at 2:47 am

    Function parameters take variable names without the % symbol, simply remove them.

    I also want to point out that if the second parameter is meant to be a regular expression,
    instead of a variable containing a regular expression, you will need quotes around it.
    As is your script passes an empty string as the pattern which will always return 1
    (failure is interpreted as a variable with an empty string associated with it.).
    To quote Lexikos:

    “An empty string, when compiled as a regex pattern, will match exactly
    zero characters at whatever position you attempt to match it. Think of
    it this way: For any position n in any string, the next 0 characters
    are always the same.”

    Because you are simply truth testing,
    or finding the index I want to point out that Autohotkey has a useful shorthand operator for this.

    string := "this is a test"
    
    f1::
    result := RegExMatch(string, "\sis")
    traytip,, %result%
    Return
    
    f2::
    result := string ~= "\sis"
    traytip,, % result
    Return
    

    These hotkeys both do the same thing; the second uses the shorthand operator ~=
    and notice how the traytip parameter in the second example has only one %

    When you start a command parameter with a % that starts an expression,
    and within an expression variables are not enclosed with %.

    The ternary operator ?: is also very useful:

    string := "this is a test"
    f3::traytip,, % (result := string ~= "\sis") ? (result) : ("nothing")
    

    It might look complicated but it’s very simple.
    Think of
    % as if
    ? as then
    : as else
    If (true) then (a) else (b)
    % (true) ? (a) : (b)

    A variable will be evaluated as False if 0 (or nothing) is assigned to it.
    But in this example “\sis” is matched and the index of the space is returned (5),
    so it is evaluated as True.

    You can read more about variables and operators here:
    http://l.autohotkey.net/docs/Variables.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a building script that needs the installdir registry key for visual
I'm currently writing a program that has debug output strewn throughout it. This is
I'm currently writing a small python app that embeds cherrypy and django using py2app.
I am currently writing an app that calls for the recording and real time
We're currently writing an application for which IT has already purchased hardware for. Their
I am writing a Perl script that is run by a user and makes
I'm writing a (PHP) script that serves files to the client. Among others, the
I'm currently using a cron job to have a perl script that tells my
I am writing a script that will copy Valgrind onto whatever shelf that we
I'm currently writing an msbuild script and having issues deleting *.vshost.exe . Before I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.