Help with FileSelectFile check if contains space(s) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tomer
Posts: 282
Joined: 21 Aug 2016, 05:11

Help with FileSelectFile check if contains space(s)

24 Mar 2019, 03:52

Code: Select all

FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt; *.doc)
if SelectedFile =
    MsgBox, The user didn't select anything.
else
    MsgBox, The user selected the following:`n%SelectedFile%
before the msgbox appears i need 2 checks please:

1. if the format file is not "txt" = dont continue!
2. if the content of the txt file is contains space(s) = dont continue! (new lines its ok)

thanks in advance!
User avatar
lmstearn
Posts: 232
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: Help with FileSelectFile check if contains space(s)

24 Mar 2019, 09:43

Code: Select all

if SelectedFile
{
FileRead, SelectedFileContents , %SelectedFile%
if InStr(SelectedFile, ".lnk", False, StrLen(SelectedFile) - 4)) && !InStr(SelectedFileContents, %A_Space%)
; Proceed
}
Edit:
Sorry, it should have been:

Code: Select all

if SelectedFile
{
FileRead, SelectedFileContents , %SelectedFile%
if InStr(SelectedFile, ".txt", False, StrLen(SelectedFile) - 4) && !InStr(SelectedFileContents, %A_Space%)
; Proceed
}
Last edited by lmstearn on 26 Mar 2019, 08:17, edited 1 time in total.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
Tomer
Posts: 282
Joined: 21 Aug 2016, 05:11

Re: Help with FileSelectFile check if contains space(s)

26 Mar 2019, 00:06

ty lmstearn but i got : Unexpected ")"
couldnt find the problem
GEV
Posts: 791
Joined: 25 Feb 2014, 00:50

Re: Help with FileSelectFile check if contains space(s)  Topic is solved

26 Mar 2019, 02:49

Code: Select all

FileSelectFile, SelectedFile, 3, , Open a file, Text Documents (*.txt; *.doc)
if SelectedFile =
    MsgBox, You didn't select anything.
else
if (SubStr(SelectedFile, - 2) != "txt")
    MsgBox, You didn't select a text file.
else
{
	FileRead, SelectedFileContents, %SelectedFile%
	if !InStr(SelectedFileContents, " ")
	{
		MsgBox, continue! ; do sth
	}
	else
	    MsgBox, The content of the selected file contains space(s).
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Cerberus, Flipeador, maxkill, Thetaburn and 71 guests