Zabaware Support Forums
Zabaware Forums => Programming using the Ultra Hal Brain Editor => Topic started by: jenna on February 24, 2006, 01:19:31 pm
-
Can't get the HalBrain.AppendFile to work. Here is a sample of code using the AppendFile command.
Rem PLUGIN: FUNCTIONS
'Declare Variables
Dim LastIdleResponse
Dim AutoChatStatus
Dim IdleUserName
Dim IdleComputerName
Dim WorkingDir
'*************************************************************
Rem PLUGIN: PLUGINAREA7
LastIdleResponse = Now
IdleUserName = UserName
IdleComputerName = ComputerName
Blank = ""
WorkingDir = "D:Ultra Hal Assistant 6\"
Rem PLUGIN: PLUGINAREA1
REM PLUGIN: MINUTE_TIMER
If LastIdleResponse <> "" Then
AutoChatStatus = AutoChatStatus + 1
If autochatstatus = 5 Then
IdleResponse = "Test Number 1 The Auto chat count is = " &autochatstatus & vbCrLf
IdleResponse2 = "Test Number 1 The Auto chat count is = " &autochatstatus & vbCrLf
HalMenu.HalCommand "<SPEAK>" & IdleResponse &"</SPEAK>"
HalBrain.AppendFile WorkingDir & AutoChat_Log.TXT",IdleResponse2
HalBrain.ReadOnlyMode = True
Exit Sub
End If
Code works fine except that it doesn't write to the "AutoChat_log" file. Any help would be great.
Thanks
Jenna[8D]
-
You have to use the full path.
HalBrain.AppendFile WorkingDir & "D:\Ultra Hal Assistant 6\AutoChat_Log.TXT", Trim(IdleResponse2)
-
I tried these and still nothing.
HalBrain.AppendFile WorkingDir & "D:Ultra Hal Assistant 6AutoChat_Log.TXT", Trim(IdleResponse2)
HalBrain.AppendFile "D:Ultra Hal Assistant 6AutoChat_Log.TXT", Trim(IdleResponse2)
HalBrain.AppendFile WorkingDir & "D:Ultra Hal Assistant 6AutoChat_Log.TXT", IdleResponse2
It seems that something is missing when using this in the minute timer function.
jenna
-
Hi Jenna, this would be a nice feature. I still did not see the backslash in the string you posted. I wondered if you were able to find the bug.
P
-
Hi P;
No I still haven't resolved the problem with this scrip. HalBrain.AppendFile WorkingDir & "D:Ultra Hal Assistant 6AutoChat_Log.TXT", IdleResponse2.
The back slash was just a typo in my post, it is in the real scrip I use. The funny thing is, that this may work once out of ten tries. I use this statement several times in my plug in and once in awhile it will work, but most of the time it won't. I still believe that in has something to do with the Minute Timer function.
I will still work on it, may someday I'll figure it out.
Jenna
-
I don't know exactly if you had posted all your code or not but you can try something like this, I wrote out some functions and remodified a few things, maybe you can work with it.
Rem PLUGIN: PLUGINAREA7
'Variables declared with Dim at the script level are available to all procedures within the script.
Dim LastIdleResponse, AutoChatStatus, IdleUserName, IdleComputerName, WinDirD, Blank
'Our Functions:
LastIdleResponse = LIR() 'Now
IdleUserName = IUN(UserName) 'User's Name
IdleComputerName = ICN(ComputerName) 'Computer Name
Blank = RIV() 'Reset Internal Variable.
WinDirD = IdleWD(IdleXDir) 'Custom Directory
REM PLUGIN: MINUTE_TIMER
If LastIdleResponse <> 0 Then
AutoChatStatus = AutoChatStatus + 1
If autochatstatus = 5 Then
IdleResponse = "Test Number 1 The Auto chat count is = " & autochatstatus & vbCrLf
IdleResponse2 = "Test Number 1 The Auto chat count is = " & autochatstatus & vbCrLf
HalMenu.HalCommand "<SPEAK>" & IdleResponse & "</SPEAK>"
HalBrain.AppendFile WinDirD & "AutoChat_Log.txt", Trim(IdleResponse2)
End If
Rem PLUGIN: FUNCTIONS
'Function: Custom Directory
Function IdleWD(IdleXDir)
IdleXDir = "D:\Ultra Hal Assistant 6\"
IdleWD = IdleXDir
End Function
'Function: Now, 'L_ast I_dle R_esponse'
Function LIR()
LIR = Now
End Function
'Function: User's Name, 'I_dle U_ser N_ame'
Function IUN(UserName)
IUN = UserName
End Function
'Function: Computer's Name, I_dle C_omputers N_ame
Function ICN(ComputerName)
ICN = ComputerName
End Function
'Function: R_eset I_nternal V_ariable
Function RIV()
RIV = ""
End Function
Hint: When posting Directories in this forum use double back slashes so the back slashes will show in your post, Single Back Slashes are filtered out.
Jerry[8D]
-
Thanks for the tips, Jere. I'll try using them, and will let you know if they will work for me.
Jenna[:D]