#197028 - 2009-12-08 09:20 PM
Kixforms help
|
morpheus_exegis
Fresh Scripter
Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
|
Hello,
I know that this is not really the appropriate forum for kixforms help but at work i cannot access kixform's forums. Seeing that Shawn might be able to help me out here and quite a few people seem to be interested in kixforms on this forum my question is as follows.
I have an almost fully developed application thanks to kixforms (couldn't have done it without it) and now users are asking for a dialog box where they can enter some text.
Basic function My program does is it opens a form and allows users to run exe files those exe files each work with two other files source and destination. the source, users are able to select thru a dialog box. and my program changes the extention by removing the last three chars from string and adding new extention to the same file name in the same directory for output. (no fancy code it looks terrible but works).
Now the users are asking for ther eot be a way to input the destination file name so that they can name it at creation rather than having to rename it all the time.
The easiest way i can think of is to remove the last section of the filepath and use a string entered by the user in a popup textbox to provide the name for the destination file.
currently i was using an array to contain the file path split at / and then to search for the . in the filename and add all previous pieces add the text obtained from user and add the extention to the string for the destination file.
Any sugesstions.. i can post my code if this is the idea that anyone would like to help me with but i am sure there are easier and better ideas for this kind of a problem.
Thanks
_________________________
-------------------------------------------- Morpheus Exegis SAND TEK
|
|
Top
|
|
|
|
#197033 - 2009-12-09 02:50 AM
Re: Kixforms help
[Re: morpheus_exegis]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
You might want to look at the PathSplit() UDF - latest version is in the UDF Library on my web site. It was written specifically to take a variable path and return an array of 4 elements - Server (if path begins with "\\", null otherwise), Share OR drive letter, Directory Path, and Filename. This lets you quickly manipulate any component and reassemble it. With the function, the complete path can be broken down by $aryFileParts = PathSplit('\\server\share\folder1\folder2\filename.ext') which would return elements (1)=server, (2)=share, (3)=folder1\folder2, (4)=filename.ext.
Renaming a file extension is as simple as$Filename = Join(Split($Filename, '.txt'), '.doc) , which changes the .TXT extension to .DOC in this example.
Unless I misunderstood, it seems like your question is more logic than GUI, no?
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#197065 - 2009-12-10 05:02 PM
Re: Kixforms help
[Re: Glenn Barnas]
|
morpheus_exegis
Fresh Scripter
Registered: 2009-09-11
Posts: 9
Loc: Ontario, Canada
|
That PathSplit UDF is a definite genius touch to my project and resolves one of the three problem i posted the other two are How can i Reference just a single element in an Array. I am thinking
Also the third problem How can i get a textbox prompt to popup and have just a textbox and a ok button. Is this pgoing to be a new form that i will have to show. Is there an easier way?
I appreciate your reply Glen. It always comes with the point that i will remember for other projects too.
_________________________
-------------------------------------------- Morpheus Exegis SAND TEK
|
|
Top
|
|
|
|
#197066 - 2009-12-10 06:32 PM
Re: Kixforms help
[Re: morpheus_exegis]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4563
Loc: USA
|
Using Glenns example... (you are right on track)
$aryFileParts = PathSplit('\\server\share\folder1\folder2\filename.ext')
$server=$aryFileParts[0]
$share=$aryFileParts[1]
$folder=$aryFileParts[2]
$file=$aryFileParts[3]
Are you just looking for an input box? This little nugget was just recently posted:
Function InputBox($sPrompt,Optional $sTitle,$sDefaultValue)
Dim $sc
$sc = CreateObject("ScriptControl")
$sc.language = "VBScript"
$inputbox = $sc.Eval('Inputbox("' + $sPrompt + '","' + $sTitle + '","' + $sDefaultValue + '")')
EndFunction
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1205 anonymous users online.
|
|
|