PDA

View Full Version : Bug with INI files in 98


dallasfreak2
10-24-2003, 05:14 PM
I have found what appears to be a bug in the Autoplay menu

this works fine in 2000/XP:

<IR_ACTIONS_LIST>
<Action name="Get Value Names">
<Type>103</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%InstallTypes%</Variable>
<FileName>\\tech-server\software\menu\install.ini</FileName>
<Section>INSTALLTYPES</Section>
</Action>
</IR_ACTIONS_LIST>

and will return a string such as
full;;default;;typical;;preventive

but in 98 the same syntax returns an empty string

the ini file is setup as:

[INSTALLTYPES]
Full="Full"
Typical="Typical"
Minimum="Minimum"
House="House"
Preventive="Preventive"
Custom="Custom"

If anyone has found a workaround, it would be appreciated.

It is not related to network rights, updates ort anything else I have seen. The menu can pullother values from the ini file iof i specify the value itself. I jsut can not seem to get the ValueNames to be pulled.

dallasfreak2
10-24-2003, 05:51 PM
this bug appears on Windows Me also according to:


this thread (http://www.indigorose.com/forums/showthread.php?s=&threadid=2791)

http://www.indigorose.com/forums/showthread.php?s=&threadid=2791

I assume it also effects Windows 95 as well.

dallasfreak2
10-25-2003, 12:42 AM
After about 4 hours of coding, I have found a sutable workaround for this bug, and am willing to share it with others. One nice feature that other scripting languages have, which Autoplay should have is user defined functions. It would make things quite easier. maybe for version 5??

The buggy function is:
%ValueNames% = INIFile.GetValueNames ("%SrcDir%\Program Files\My Files\MyINI.ini", "MySection")

This below is an alternative piece of code for that function.
Notice the beginning variables. They need to be assigned in the same way as INI.GetValueNames
The %DF_SectionSeperator% is the sperator between INI File Sections
ie.
[MyFirstSection]
MYvalue=1234
;;**;;
[MySecondSection]
MyValue=3456
I hope this will help someone else until the bug is fixed.

<< Build Time constants are:
#ASC_LF# = 10
#ASC_CR#=13

// VARIABLES
// INI File Location
%DF_INI_FILE% = "%SrcDir%\Program Files\My Files\MyINI.ini"
// Section Name
%DF_SectionName% = "MySection"
// Section Seperator
%DF_SectionSeperator% = ";;***;;"

%x% = "0"
%DF_FileText% =TextFile.Read ("%DF_INI_FILE%")
%DF_NumIniSect% = String.CountDelimitedStrings ("%DF_FileText%", "%DF_SectionSeperator%")
WHILE (%x% < %DF_NumIniSect%)
%DF_String1% = String.GetDelimitedString ("%DF_FileText%", "%DF_SectionSeperator%", %x%)
%DF_String1S2% = String.GetDelimitedString ("%DF_String1%", "]", 0)
%DF_String1S2Len% = String.GetLength ("%DF_String1S2%")
%DF_String1S2Len% = Evaluate (%DF_String1S2Len% - 1)
%DF_String1S2% = String.Mid ("%DF_String1S2%", 1, %DF_String1S2Len%)
IF (%DF_String1S2%=%DF_SectionName%)
%DF_String1S3% = String.GetDelimitedString ("%DF_String1%", "]", 1)
%DF_String1S3Len% = String.CountDelimitedStrings ("%DF_String1S3%", "=")
%y% = "1"
%DF_SubReturnVar% = ""
WHILE (%y% < %DF_String1S3Len%)
%DF_String1S4% = String.GetDelimitedString ("%DF_String1S3%", "#ASC_CR##ASC_LF#", %y%)
%DF_String1S5% = String.GetDelimitedString ("%DF_String1S4%", "=", 0)
%DF_SubReturnVar% = "%DF_SubReturnVar%;;%DF_String1S4%"
%y% = Evaluate (%y% + 1)
END WHILE
END IF
%x% = Evaluate (%x% + 1)
END WHILE
%DF_SubReturnVarLength% = String.GetLength ("%DF_SubReturnVar%")
%DF_SubReturnVarLength% = Evaluate (%DF_SubReturnVarLength%-2)
%ReturnVar% = String.Mid ("%DF_SubReturnVar%", 2, %DF_SubReturnVarLength%)
%ValueNames% = "%ReturnVar%"

dallasfreak2
10-27-2003, 06:51 PM
if you want to tottally replace the built in function, the following updated code works well

using GOTO and LABEL -- it can simulate custom functions like other scripting languages

Design constants

#ASC_CR# 13
#ASC_LF# 10

Function:
// location of the ini file
%DF_INi_FILE_LOCATION% = "C:\WHATEVER.INI"
// section for the value names you want
%DF_WhatYouAreLookingFor% = "INSTALLTYPES"
// label to return to the part of the code the subroutine was called from
%DF_RETURNLABEL% = "DIALOG"
GOTO ("VALUENAMES")
DIALOG
// lets get the return vlaue and assign it to our variable
%InstallTypes% = "%DF_ReturnVar%"
%Result% = Dialog.MessageBox ("Title", "%InstallTypes%", Ok, Question)
//done with script, lets jump over the custom function
GOTO ("ENDLABEL")
// the valuenames function replacement
VALUENAMES
IF (%IsWin95% OR %IsWin98% OR %IsWinME% = "TRUE")
%DF_X% = "1"
%DF_InstallFileText% =TextFile.Read ("%DF_INi_FILE_LOCATION%")
%DF_NumberOfSectionsInInstallFileText% = String.CountDelimitedStrings ("%DF_InstallFileText%", "]#ASC_CR#")
WHILE (%DF_X% < %DF_NumberOfSectionsInInstallFileText%)
%DF_FirstPartOfInstallFileText% = String.GetDelimitedString ("%DF_InstallFileText%", "[", %DF_X%)
%DF_FirstSectionOfFirstPartOfInstallFileText% = String.GetDelimitedString ("%DF_FirstPartOfInstallFileText%", "]", 0)
IF (%DF_FirstSectionOfFirstPartOfInstallFileText%=%DF _WhatYouAreLookingFor%)
%DF_SecondSectionOfFirstPartOfInstallFileText% = String.GetDelimitedString ("%DF_FirstPartOfInstallFileText%", "]", 1)
%DF_SecondSectionOfFirstPartOfInstallFileTextCount % = String.CountDelimitedStrings ("%DF_SecondSectionOfFirstPartOfInstallFileText%", "=")
%DF_Y% = "1"
%DF_SubReturnVar% = ""
WHILE (%DF_Y% < %DF_SecondSectionOfFirstPartOfInstallFileTextCount %)
%DF_FirstValueNameLine% = String.GetDelimitedString ("%DF_SecondSectionOfFirstPartOfInstallFileText%", "#ASC_CR#", %DF_Y%)
%DF_FirstValueName% = String.GetDelimitedString ("%DF_FirstValueNameLine%", "=", 0)
%DF_SubReturnVar% = "%DF_SubReturnVar%;;%DF_FirstValueName%"
%DF_Y% = Evaluate (%DF_Y% + 1)
END WHILE
END IF
%DF_X% = Evaluate (%DF_X% + 1)
END WHILE
%DF_SubReturnVarLength% = String.GetLength ("%DF_SubReturnVar%")
%DF_SubReturnVarLength% = Evaluate (%DF_SubReturnVarLength%-2)
%DF_ReturnVar% = String.Mid ("%DF_SubReturnVar%", 2, %DF_SubReturnVarLength%)
%DF_ReturnVar% = String.Replace ("%DF_ReturnVar%", "#ASC_LF#", "")
%DF_ReturnVar% = String.Replace ("%DF_ReturnVar%", "#ASC_CR#", "")
ELSE
%DF_ReturnVar% = INIFile.GetValueNames ("%DF_INi_FILE_LOCATION%", "%DF_WhatYouAreLookingFor%")
END IF
GOTO ("%DF_RETURNLABEL%")
// end of script
ENDLABEL

Lorne
10-28-2003, 09:57 AM
Originally posted by dallasfreak2
I have found what appears to be a bug in the Autoplay menu

this works fine in 2000/XP:

<IR_ACTIONS_LIST>
<Action name="Get Value Names">
<Type>103</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%InstallTypes%</Variable>
<FileName>\\tech-server\software\menu\install.ini</FileName>
<Section>INSTALLTYPES</Section>
</Action>
</IR_ACTIONS_LIST>

and will return a string such as
full;;default;;typical;;preventive

but in 98 the same syntax returns an empty string


I suspect this has something to do with the UNC path you're using. Are you sure the Win9x machines are able to resolve that path? Especially with the hyphen in the server name?

IIRC, Win9x used to have trouble with some UNC names that were valid in NT. I can't remember the exact reason, though, but it might be something to look into.

Have you tried accessing the INI file locally? See if that makes any difference. You could also try mapping the path to a drive letter, and using the drive letter instead of the server & share name. (It would help us narrow this down, if it is a bug.)

dallasfreak2
10-28-2003, 05:58 PM
yes -- have tried mapping locally, and not across a server. The server is just an inhouse thing, but it does appear locally as well.

I have not noticed any other bug yet between 2k and 98.

The workaround does wirk on both oses though even without the Iswin9x check... but at an increase in execution time -- not much just bout 2 seconds

What is odd though, and makes me think its jaut a bug with this one function, is that reading the ini as a text file works fine, as well as all of the other ini file functions regardless of rather its locally, across share, or mapped locally.

Simple test -- blank menu -- have it read the valuenames of an ini file in c:\whatever.ini then echo them via dialog box -- it will be blank in 9x but work in 2k

Adam
10-29-2003, 02:30 PM
I have tested this out and it appears as though it is a bug in AutoPlay 4.0.0.5. I have documented this for the developers.

Thank you for the information regarding the workaround.

dallasfreak2
10-29-2003, 06:18 PM
heh - long time no see Adam -- used to post to the version 3 forums quite often

any chance on getting custom functions in the next major release to make repeatitive code snippets more automated?

or a way to use GOTO to jump to a section of code on another page? (That way a user can have a "page" of nothing but scripts such as this workaround and then go back to the orignal page)

Colin
10-29-2003, 06:48 PM
You can count on functions being in the next version... :)