Page 1 of 1 1
Topic Options
#196891 - 2009-11-30 08:52 PM adding quotes to the filepath
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
Hello,

I am a fresh scripter for Kix. Just discovered it a few days ago when an unusual request came through. I work with Bat files frequently and someone asked me to make a GUI forntend for it. Kix works great and KixForms is an excellent piece of software. So the problem is probably the way i am thinking about this problem.

I need to pass parameters to another program in cmd it is easy and goes something like this


 Code:
 compress Source Destination FLAGS


I have the KixForm application getting the filepath and passing it onto the appropriate variable. so essentially what i have is :

 Code:
SHELL 'M:\fullpath\Compress '+ $Source + $Dest +' FLAGS FLAGS FLAGS'


the program runs as expected but since the file path has spaces it breaks the source address into pieces whereever the space is encountered. FOr Example : c:\Documents and Settings\username gives me 'Settings\username' is an invalid parameter.

Usually quotes around the path resolve this issue. I have tried ', '', ", "" and several other variation of quotes but all to no avail. I just need to know how to manipulate strings in a very basic fashion by adding quotes around all of it so that it can be passed as one string per parameter.

My Strings are already variables.

Thanks to anyone and everyone who helps me out with this.
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

Top
#196894 - 2009-11-30 10:42 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
just try :
 Code:
SHELL '"M:\fullpath\Compress" "'+ $Source + '" "' + $Dest + '" FLAGS FLAGS FLAGS'
_________________________
Christophe

Top
#196896 - 2009-12-01 12:46 AM Re: adding quotes to the filepath [Re: ChristopheM]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
If you were in my scripting class, I'd say "build your command string in small sections, then display it instead of running it. Does it look right? Then replace the display command with the execute command.."

Kind of like this:
 Code:
$Cmd = '"M:\fullpath\compress" '     ; base command
$Cmd = $Cmd + '"' + $Source + '" '   ; add the source argument
$Cmd = $Cmd + '"' + $Dest + '" '     ; add the dest argument
$Cmd = $Cmd + 'Flag flag FLAG'       ; add switches/flags
'About to run: ' ? $Cmd ?
; Uncomment the next line and comment the prior line after confirming the syntax
;Shell $Cmd
Note that every line where you build $Cmd ends with a space, except the last. Alternatively, each line could BEGIN with a space (except the first) - a matter of choice. By displaying this, I can see what the command will look like before I run it. I can even copy it from the screen and paste it back to test it manually.

In many of my production scripts, I define a global var called $DEBUG, and use the Msg() library (download from my web site/resources/Kix UDF Library). It contains a Dbg() function that will output the message only if $DEBUG is set. Allows me to easily enable/disable debug messages at any time.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196907 - 2009-12-01 04:26 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
Glenn's suggestion worked great. I had only tried doubling the quotes not different types of quotes. Thank youvery much Glenn.

Within the same project i have a few more questions If this post is unsuitable here i can start a new thread. the problems are as follows:

1) @crlf macro doesnt seem to add a new line to a textbox.text field. Related to kix forms. The result of my current attempts is as follows:

 Code:
$Textbox.text=$Textbox.text+@CRLF+$message+@CRLF+$Form.OpenFileDialog.Filename

results in boxes instead of the carriage return and the line feed chars


2) how can i read a simple text file into a textbox.text field. Preferably appended to whatever i have there now.


3) How can i package external exe dll and other files including kix scripts to one neat exe application. I dont want users to have any chance of poking their noses in the sensitive data file and key for the compressor program.

4) a way to edit / concatenate strings. i want to be able to trim the last three characters of the string and add new ones. I can successfully add but i didnt see any String manipulation so far in Kix.

Thanks


Edited by morpheus_exegis (2009-12-01 06:45 PM)
Edit Reason: readded questions
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

Top
#196911 - 2009-12-01 05:02 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
1 and 2... I suggest starting a new thread in COM scripting or posting the question to kixforms.org forums.

3. Search the board/google for kix2exe.

4. See the link in my signature: Left, Right, Substr to start with.

Top
#196912 - 2009-12-01 05:06 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
1) @crlf macro doesnt seem to add a new line to a textbox.text field.


Set the "multiline" property to TRUE.

 Quote:
2) how can i read a simple text file into a textbox.text field.


Look for the ReadFile() UDF.

 Quote:
4) a way to edit / concatenate strings. i want to be able to trim the last three characters of the string and add new ones. I can successfully add but i didnt see any String manipulation so far in Kix.


Must try harder - there are quite a few \:\)

Trim(), Left(), Right(), SubStr() and InStr() are some of the more useful string manipulation function.

Top
#196913 - 2009-12-01 05:12 PM Re: adding quotes to the filepath [Re: Allen]
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
I was moving my post when it got answered by Richard. if it is not resolved i will post in a new thread otherwise i will repost the questions here for other to see.

kix2exe is a nice tool but i was unable to package other exe dlls etc with my script. I will search google for similiar posts.

In response to Richards post how do i implement a UDF and specific instructions. I know Glenn's site probably has them.

Sorry new scripter so i am very out of the loop here.


Thanks
Morpheus
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

Top
#196914 - 2009-12-01 05:16 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Kix2Exe now has a gui now and I can, without a doubt, tell you, you can package other exes, etc in the package.

FAQs and How tos: http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=5&page=1

Look for "How to use a UDF" (User Defined Function)

Top
#196920 - 2009-12-01 06:43 PM Re: adding quotes to the filepath [Re: Allen]
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
What i get is :

ERROR : undefined variable [sid]!
Script: C:\WINDOWS\TEMP\kix2exe~50421\kix2exe.dat
Line : 30



Single kix file packaging is simple and easy. but as soon as i include the files it get this message.
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

Top
#196927 - 2009-12-02 08:43 AM Re: adding quotes to the filepath [Re: morpheus_exegis]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Is "sid" a variable on line 30 of your script?

If not (and this is only a guess as I don't know or use kix2exe) you may have configured the package to run one of your non-KiXtart files in the KiXtart command interpreter.

Top
#196984 - 2009-12-03 08:56 PM Re: adding quotes to the filepath [Re: morpheus_exegis]
Senser Offline
Fresh Scripter
*****

Registered: 2005-05-26
Posts: 32
Loc: The Netherlands
This looks like a bug in Kix2Exe. Including other files into the package should not be a problem at all.

What version of Kix2Exe are you using?
_________________________
Kix2Exe - Kixtart Script Packager - Check : http://kix2exe.ramonitor.nl

Top
#196996 - 2009-12-04 09:49 PM Re: adding quotes to the filepath [Re: Richard H.]
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
Sorry i was working on a few other things that took precedence for the last two days. I am back on this project.

Richard, There is no sid variable in my entire program.
the error only occurs if i include dll's i have successfully added the exe's and other files.

Update: KIX just fails at creating the file

Error: Failed creating package C:\Documents and Settings\Syeshi.PDC-MILTON\Desktop\Scripts\Business\Final\Util.exe


Packaging aborted!


the SID was caused by an extra + sign at the end of one of the strin concats


Edited by morpheus_exegis (2009-12-04 10:32 PM)
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

Top
#196997 - 2009-12-04 10:03 PM Re: adding quotes to the filepath [Re: Richard H.]
morpheus_exegis Offline
Fresh Scripter

Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
How can i split an array to String? how do i traverse an array?


nvm - figured it out. Also figured out how to use the udf.


Edited by morpheus_exegis (2009-12-04 10:29 PM)
Edit Reason: Update:
_________________________
--------------------------------------------
Morpheus Exegis
SAND TEK

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
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.064 seconds in which 0.023 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