|
-
June 21st, 2001, 12:52 PM
#1
INI Files
Hi all,
I'm using this code to get info from an ini file:
'stuff for ini file
public Declare Function GetPrivateProfileSection Lib "kernel32" _
Alias "GetPrivateProfileSectionA" (byval lpAppName as string, _
byval lpReturnedString as string, byval nSize as Long, _
byval lpFileName as string) as Long
public Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" (byval lpApplicationName _
as string, byval lpKeyName as Any, byval lpDefault as string, _
byval lpReturnedString as string, byval nSize as Long, _
byval lpFileName as string) as Long
public Declare Function WritePrivateProfileSection Lib "kernel32" _
Alias "WritePrivateProfileSectionA" (byval lpAppName as string, _
byval lpString as string, byval lpFileName as string) as Long
public Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (byval lpApplicationName _
as string, byval lpKeyName as Any, byval lpString as Any, _
byval lpFileName as string) as Long
public Sub GetIniSetupInfo()
Dim strFile as string
'Dim Frstrun as Long
Dim strService as string
Dim lngDealerName, lngAsciiDirectory as Long
Dim lngAsciiFileName, lngAccessDatabaseName as Long
Dim lngAccessTableName, lngArrFieldLength as Long
Dim lngArrFieldType, lngArrRepeatColumnValue as Long
Dim lngNextProgramToRun, lngProcommScript as Long
Frstrun = Frstrun + 1
If Frstrun = 1 then strService = "ServiceCall1"
If Frstrun = 2 then strService = "ServiceCall2"
If Frstrun = 3 then strService = "ServiceCall3"
If Frstrun = 4 then strService = "ServiceCall4"
Dim retval
on error GoTo ErrorHandler
'//get Info From INI File
strFile = App.Path & "\datadefinition.ini"
'//Create Room In The string Variables for Returned Strings
DealerName = Space(255)
AsciiDirectory = Space(255)
AsciiFileName = Space(255)
AccessDatabaseName = Space(255)
AccessTableName = Space(255)
ArrFieldLength = Space(255)
ArrFieldType = Space(255)
ArrRepeatColumnValue = Space(255)
NextProgramToRun = Space(255)
ProcommScript = Space(255)
'//get the info from the INI file
lngDealerName = GetPrivateProfileString(strService, "DealerName", "0", DealerName, 255, strFile)
lngArrFieldLength = GetPrivateProfileString(strService, "ArrFieldLength", "0", ArrFieldLength, 255, strFile)
lngArrFieldType = GetPrivateProfileString(strService, "FieldType", "0", ArrFieldType, 255, strFile)
lngArrRepeatColumnValue = GetPrivateProfileString(strService, "RepeatColumnValue", "0", ArrRepeatColumnValue, 255, strFile)
lngAsciiDirectory = GetPrivateProfileString(strService, "AsciiDirectory", "0", AsciiDirectory, 255, strFile)
lngAsciiFileName = GetPrivateProfileString(strService, "AsciiFileName", "0", AsciiFileName, 255, strFile)
lngAccessDatabaseName = GetPrivateProfileString(strService, "AccessDatabaseName", "0", AccessDatabaseName, 255, strFile)
lngAccessTableName = GetPrivateProfileString(strService, "AccessTableName", "0", AccessTableName, 255, strFile)
lngNextProgramToRun = GetPrivateProfileString(strService, "NextProgramToRun", "0", NextProgramToRun, 255, strFile)
lngProcommScript = GetPrivateProfileString(strService, "ProcommScript", "0", ProcommScript, 255, strFile)
'//Stuff Returned Into Global Variables
DealerName = Replace(RTrim(DealerName), Chr(0), "")
AsciiDirectory = Replace(RTrim(AsciiDirectory), Chr(0), "")
AsciiFileName = Replace(RTrim(AsciiFileName), Chr(0), "")
AccessDatabaseName = Replace(RTrim(AccessDatabaseName), Chr(0), "")
AccessTableName = Replace(RTrim(AccessTableName), Chr(0), "")
ArrFieldLength = Replace(RTrim(ArrFieldLength), Chr(0), "")
ArrFieldType = Replace(RTrim(ArrFieldType), Chr(0), "")
ArrRepeatColumnValue = Replace(RTrim(ArrRepeatColumnValue), Chr(0), "")
NextProgramToRun = Replace(RTrim(NextProgramToRun), Chr(0), "")
ProcommScript = Replace(RTrim(ProcommScript), Chr(0), "")
Exit Sub
ErrorHandler:
MsgBox Err.Number & " " & Err.Description
'retval = MsgBox("datadefinition.ini File Missing Or Corrupt. This Must Be Fixed So That The Previous Shift Screens Will Work", vbOKOnly)
End Sub
The problem I am having is that i want three variable to hold arrays of info which look like this:
ArrFieldLength="11,7,31,26,26,11,12,11,15,9,3,6,5,6,9,11"
How can I do this... with an INI File?????
Thanks for any ideas.
DJ Mclean
-
June 21st, 2001, 07:05 PM
#2
Re: INI Files
To write into INI file
strTemp = ""
for i=1 to 3
srtTemp = strTemp & "," & CStr(NumberArr(i))
next
To read from INI file
Dim strTempArr() as string
Dim nNumberArr() as string
strTempArr = Split(strStrinfFromIni, ",")
Redim nNumberArr(0,UBound(strTempArr))
for i = 0 to UBound(strTempArr)
nNumberArr(i) = CInt(strTempArr(i))
next
Andy Tower
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|