Page 1 of 1 1
Topic Options
#174104 - 2007-02-21 01:57 PM How-To handle embedded space in a UNC?
SteveWolfe Offline
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:

 Code:
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
#174106 - 2007-02-21 02:12 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
When you say that the error occurs on the first space, what do you mean?

The lines look OK, and there should be no problem with embedded spaces.

The only thing that I can think off the top of my head is that you have an unbalanced (missing) quote character earlier in your script.

Top
#174107 - 2007-02-21 02:21 PM Re: How-To handle embedded space in a UNC? [Re: Richard H.]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
I'll re-run the script and take a peek at the error.

Be back in just a minute or two ...

Top
#174108 - 2007-02-21 02:32 PM Re: How-To handle embedded space in a UNC? [Re: Richard H.]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
This is what I get from the command processor (DOS window):


Entering MEPRS Pop Up Module ...
'\\nvzramcw3vn101\6-MDG-G\Data\6' is not recognized as an internal or external command, operable program or batch file.
Press any key to continue . . .

I'll do some closer scruntiny of the code and if I don't lay eyes on anything, I'll post a big chunk of it, because sometimes due to familiarity you just don't see things quite right.

v/r

Steve

Top
#174109 - 2007-02-21 02:46 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
this is a small thing, you should not place macros inside quotes:
this line:
 Code:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\@USERID")

should be:
 Code:
If Not Exist("\\nvzramcw3vn101\6-MDG-G\Data\6 MDG Network Drives\Users\"+@USERID)

and inside the Else
change these lines:
 Code:
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:
 Code:
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
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174110 - 2007-02-21 02:46 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok,

It looks like you are passing something to DOS via RUN or SHELL, as the error message is actually from the DOS interpreter, not KiXtart.

If you are trying to start a command or batch file which is on the share with spaces in it would explain the error.

BTW don't use "QUIT" without a parameter, it can cause problems.

Top
#174116 - 2007-02-21 03:54 PM Re: How-To handle embedded space in a UNC? [Re: Benny69]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
Thank You, made those changes and the command processor errors went away, but now I'm nit getting my Excel automation.

I'll do a bit more troubleshooting and see what's up, but I'll probably be back here whining for some help.

v/r

Steve

Top
#174117 - 2007-02-21 04:20 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
SteveWolfe Offline
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:

 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 Offline
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)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174119 - 2007-02-21 04:35 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I think that this is what you want to do:
 Code:
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
#174123 - 2007-02-21 05:03 PM Re: How-To handle embedded space in a UNC? [Re: Richard H.]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
Studying your code now while chomping on an egg salad sandwich.

More compact than mine ...

See you all in a bit.

OBTW, Thanks for the help, I believe my biggest problem was overcomplicating the string expressions and not dealing with the macro expansions correctly.

I'll post my $lmonth solution in about 45 minutes or so ...

Thanks again ....

v/r

Steve

Top
#174130 - 2007-02-21 08:11 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
I haven't finished thescript changes yet but I think I have my arms around the basic problem.

It's time leave and I'll pick it up again tomorrow.

Thanks for the help.

v/r

Steve

Top
#174172 - 2007-02-22 08:44 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
SteveWolfe Offline
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.

 Code:

; 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
#174173 - 2007-02-22 09:00 PM Re: How-To handle embedded space in a UNC? [Re: Richard H.]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
Should I always quit out with a "0" if everything is OK?
Top
#174174 - 2007-02-22 09:18 PM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
Just found out what the problem was -- don't use quotes inside the $lmonth and $cmonth vars when testing for existence.

I'm done.

Thanks for the help!

Top
#174189 - 2007-02-23 05:39 AM Re: How-To handle embedded space in a UNC? [Re: SteveWolfe]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If you really want to clean up yoru code you'd use
 Code:
$rc=setoption('explicit','on')
$rc=setoption('nomacrosinstrings','on')
$rc=setoption('novarsinstrings','on')
_________________________
There are two types of vessels, submarines and targets.

Top
#174191 - 2007-02-23 01:33 PM Re: How-To handle embedded space in a UNC? [Re: Sealeopard]
SteveWolfe Offline
Fresh Scripter

Registered: 2005-08-10
Posts: 20
Loc: MacDill AFB, FL
Yes, I do really want to clean up my code and I guess I need to go back and read the manual more closely and gain a clearer understanding of the options you just set ...

v/r

Steve

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.159 seconds in which 0.121 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org