#174104 - 2007-02-21 01:57 PM
How-To handle embedded space in a UNC?
|
SteveWolfe
Fresh Scripter
Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
|
Last night we switch over to a base Comm server, the NCC gave us this UNC:
\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\
Our original UNC was:
\\fsnvzrmsana\Users\ -- No problems with this UNC.
The script lines that are complaining are these:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@userid")
; If the user does not have a mappable homedrive share, we need to create it
; Here the script logs the fact there is homeshare, then exits to the normal
; medical.bat continuation
CLS
$FH = FreeFileHandle()
; Some troubleshooting statements to follow ...
;?
;? "File Handle found: "+$FH
;?
;Sleep 3
;? "Just before open statement ..."
;?
;Sleep 3
If Open($FH,"\\fsnvzrmsanb\organization\meprs_cm\MEPRS_LOG.TXT",5) = 0
$x = WriteLine($FH,@DATE + " " +@TIME + " U: Drive Not Found for " + @USERID + " " + @CRLF + @CRLF)
Close($FH)
?
? "Exiting MEPRS Pop-Up Module ..."
?
Sleep 2
Quit
EndIf
?
?
Sleep 3
Else
; This determines whether they have the meprs folder under their homedrive share
; Getting here means the user has a mappable home share and it is permissioned right
If (Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@userid\meprs") = 0)
MD ("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@userid\meprs")
EndIf
EndIf
An error occurs on the first embedded space. I do not have the option of changing the UNC, at least not today -- I will have to politic for that.
How do I handle the embedded spaces?
TIA
|
|
Top
|
|
|
|
#174109 - 2007-02-21 02:46 PM
Re: How-To handle embedded space in a UNC?
[Re: SteveWolfe]
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
this is a small thing, you should not place macros inside quotes: this line:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@USERID")
should be:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\"+@USERID)
and inside the Else change these lines:
If (Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@userid\meprs") = 0)
MD ("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@userid\meprs")
EndIf
to these lines:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\"+@USERID+"\meprs")
MD ("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\"+@USERID+"\meprs")
EndIf
|
|
Top
|
|
|
|
#174117 - 2007-02-21 04:20 PM
Re: How-To handle embedded space in a UNC?
[Re: SteveWolfe]
|
SteveWolfe
Fresh Scripter
Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
|
OK, I'm back - ready to wimper a bit.
I have isolated the problem to this snippet of code:
;************************************ SET MONTH VARIABLE *******************************************************
$mn='0','January','February','March','April','May','June','July','August','September','October','November','December'
;************************************ SET MONTH VARIABLE *******************************************************
Dim $lmonth2
Dim $cmonth2
$lmonth2 = $mn[@monthno-1] + $year + @userid + ".xls"
? "Back half of $lmonth var: " + $lmonth2
sleep 10
$lmonth = "\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\" + @userid + "\meprs\" + $lmonth2
? "This is $lmonth: " + $lmonth
Sleep 10
$cmonth = ("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\" + @userid + "\meprs\" + @month + $year + @userid + ".xls")
? "This is $cmonth: " + $cmonth
Sleep 10
Look what happens to $lmonth when I concantenate the back half with the front half? You can run this snippet and a bunch of garbage ends up on the back half. What am I doing wrong, delinating the front half incorrectly?
v/r
Steve
|
|
Top
|
|
|
|
#174118 - 2007-02-21 04:31 PM
Re: How-To handle embedded space in a UNC?
[Re: SteveWolfe]
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
$mn is an array and i don't see where you are incrementing to the next element in the array.
edit nevermind i see it now edit
edit wait,... if @monthno was 1 meaning January, with $mn[1-1] that would be $mn[0] and in your array that would be the first element in the array '0' not January as it should be. edit
Edited by Benny69 (2007-02-21 04:37 PM)
|
|
Top
|
|
|
|
#174119 - 2007-02-21 04:35 PM
Re: How-To handle embedded space in a UNC?
[Re: SteveWolfe]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I think that this is what you want to do:
Dim $asCalMonths,$sLastMonthFile,$sThisMonthFile
$asCalMonths='December','January','February','March','April','May','June','July','August','September','October','November','December'
$sLastMonthFile=$asCalMonths[@MONTHNO-1]+(@YEAR-(@MONTHNO=1))+@USERID+".xls"
$sThisMonthFile=$asCalMonths[@MONTHNO]+@YEAR+@USERID+".xls"
"Last month file="+$sLastMonthFile+@CRLF
"This month file="+$sThisMonthFile+@CRLF
|
|
Top
|
|
|
|
#174172 - 2007-02-22 08:44 PM
Re: How-To handle embedded space in a UNC?
[Re: SteveWolfe]
|
SteveWolfe
Fresh Scripter
Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
|
I'm back and have all the file specification issues resolved, but now a totally different part of the script appears to have stopped working.
; Below is the final solution to get the suckers (suckers being $cmonth and $lmonth)
; to work in the run command down in the Case statement.
; Gee, what a goat rope this has been ...
$cmonth4t = $cmonth
$cmonth = Chr(34) + $cmonth + Chr(34)
$lmonth = Chr(34) + $lmonth + Chr(34)
$Today = @date
$f = GetFileTime($cmonth4t)
$meprs = SubStr($f,1,10)
?
? "Current Month Variable"
? $cmonth4t
?
?
? "GetFileTime: " + $f
?
? "File time on Current Month: "
? "($meprs) - " + $meprs
?
? "Current date string: "
? $Today
Sleep 15
Select
Case Exist ($cmonth) ; This is the default current month condition
? "In current month select Logic ..."
If $meprs < $Today
Run 'cmd /c $cmonth'
EndIf
Case Exist ($newmeprs) ; This is the New Month condition
Copy $newmeprs $cmonth
$excel = CreateObject("excel.application")
$excel.visible = 0
$excel.displayalerts = 0
$book = $excel.workbooks.Open($lmonth)
$excel.Sheets($lmonsname).activate
$vwc = $excel.activesheet.columns(8).rows(3).value
$vocc = $excel.activesheet.columns(8).rows(4).value
$vskill = $excel.activesheet.columns(14).rows(3).value
$vdesc = $excel.activesheet.columns(13).rows(4).value
$vwca = $excel.activesheet.columns(18).rows(4).value
$vmtfd = $excel.activesheet.columns(18).rows(5).value
$vacct1 = $excel.activesheet.columns(8).rows(11).value
$vacct2 = $excel.activesheet.columns(9).rows(11).value
$vacct3 = $excel.activesheet.columns(10).rows(11).value
$vacct4 = $excel.activesheet.columns(11).rows(11).value
$vacct5 = $excel.activesheet.columns(12).rows(11).value
$vacct6 = $excel.activesheet.columns(13).rows(11).value
$vacct7 = $excel.activesheet.columns(14).rows(11).value
$vacct8 = $excel.activesheet.columns(15).rows(11).value
$vacct9 = $excel.activesheet.columns(16).rows(11).value
$vacct10 = $excel.activesheet.columns(17).rows(11).value
$excel.visible = 0
$excel.Quit()
$excel = 0
$excel = CreateObject("excel.application")
$excel.visible = 0
$excel.displayalerts = 0
$book = $excel.workbooks.Open($cmonth)
;activate the sheet with current month's short name, i.e., if September 20005 then
;the short name will be Sep 05. Develop in variable named $TabName
$excel.Sheets($Tabname).activate
$excel.ActiveSheet.Name = $Tabname
$Excel.ActiveSheet.Columns(8).Rows(2).Value = @fullname
$excel.activesheet.columns(8).rows(3).value = $vwc
$excel.activesheet.columns(8).rows(4).value = $vocc
$excel.activesheet.columns(14).rows(3).value = $vskill ; - old code
$excel.activesheet.columns(13).rows(4).value = $vdesc
$excel.activesheet.columns(18).rows(4).value = $vwca
$excel.activesheet.columns(18).rows(5).value = $vmtfd
$excel.activesheet.columns(8).rows(6).value = Left(@month,3)
$excel.activesheet.columns(8).rows(7).value = @year
$excel.activesheet.columns(8).rows(11).value = $vacct1
$excel.activesheet.columns(9).rows(11).value = $vacct2
$excel.activesheet.columns(10).rows(11).value = $vacct3
$excel.activesheet.columns(11).rows(11).value = $vacct4
$excel.activesheet.columns(12).rows(11).value = $vacct5
$excel.activesheet.columns(13).rows(11).value = $vacct6
$excel.activesheet.columns(14).rows(11).value = $vacct7
$excel.activesheet.columns(15).rows(11).value = $vacct8
$excel.activesheet.columns(16).rows(11).value = $vacct9
$excel.activesheet.columns(17).rows(11).value = $vacct10
$ = $Excel.ActiveSheet.SaveAs($cmonth)
$excel.visible = 0
$excel.Quit()
$excel = 0
; Let's see if the below statement opens the spreadsheet
; run 'cmd /c $cmonth'
If Exist ($lmonth)
Run 'cmd /c $lmonth'
Else
Run 'cmd /c $cmonth'
EndIf
Case Exist ($lmonth) ; Removed the = 1, not sure why this case exists?
Run 'cmd /c $lmonth'
Case 1
? "You are in the default case condition, nothing happened."
? "Please contact the Helpdesk at 7-9966 and report a MEPRS PopUp failure"
? "Tell the Helpdesk technician that error MPU-999 occurred."
?
? "This message will disappear in 20 seconds."
Sleep 15
EndSelect
Note when I go get the time I use the file spec without quotes, but in the run command I need the quotes. What is breaking in the above code is the If block in the first select. I'm totally clueless why it is not working. It was working just fine.
To test the above code put any filespec in you want to test against, create something in notepad ...
What I want to accomplish is if the modify date is today's date don't execute the run command -- simple Simon ..., gee frustrated in Tampa
v/r
Steve
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 874 anonymous users online.
|
|
|