Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

variable contains illegal charatcers


  • Please log in to reply
3 replies to this topic
Justin
  • Members
  • 3 posts
  • Last active: Nov 16 2014 03:40 AM
  • Joined: 26 Oct 2013
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
FormatTime, Sday,, yyyyMMdd
SetWorkingDir, C:\Users\Benny\HORSES\BS Bot
TFile = %Sday%.xls
file := FileOpen(%TFile%, r)

I get the error msg variable contains illegal character.

 

However the file name is correct. In this example todays date is 24 05 2014

So my variable is 20140524 then I add .xls

20140524.xls contains an illegal character but what it is?

 

Also given this is the correct name of the file I want to open what can I do to open a file yyyyMMdd.xls which changes name every day.



hd0202
  • Members
  • 709 posts
  • Last active: Feb 14 2016 08:05 PM
  • Joined: 13 Aug 2006
file := FileOpen(TFile, "r")

Hubert



Justin
  • Members
  • 3 posts
  • Last active: Nov 16 2014 03:40 AM
  • Joined: 26 Oct 2013
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
FormatTime, Sday,, yyyyMMdd
TFile = %Sday%.xls
MsgBox, %TFile%
SetWorkingDir, C:\Users\Benny\HORSES\BS Bot
file := FileOpen(TFile, "r")
Sleep, 3000
ExitApp

Thanks Hubert.

Such a silly oversight.

 

Still won't open the file.

Steps through line, no errors, file definitely but doesn't open the file?



hd0202
  • Members
  • 709 posts
  • Last active: Feb 14 2016 08:05 PM
  • Joined: 13 Aug 2006

How will you decide if the file is open when you don't read the file?

 

Try this code, it also loops for .xls files:

#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;FormatTime, Sday,, yyyyMMdd
;TFile = %Sday%.xls
;MsgBox, %TFile%
SetWorkingDir, C:\Users\Benny\HORSES\BS Bot
loop, *.xls
{
  msgbox, % a_loopfilename
  file := FileOpen(a_loopfilefullpath, "r")
  if isobject(file)
  {
    msgbox, %a_loopfilefullpath% is open
    ; read and process data
    Sleep, 3000
    file.close()
  }
  else
    msgbox, %a_loopfilefullpath% is not open
}
ExitApp

Hubert