Page 1 of 1 1
Topic Options
#197028 - 2009-12-08 09:20 PM Kixforms help
morpheus_exegis Offline
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 Administrator Offline
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
 Code:
$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
 Code:
$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! \:D

Top
#197065 - 2009-12-10 05:02 PM Re: Kixforms help [Re: Glenn Barnas]
morpheus_exegis Offline
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

 Code:
 $arr(1) OR $arr[1] 


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 Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Using Glenns example... (you are right on track)

 Code:
$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:

 Code:
Function InputBox($sPrompt,Optional $sTitle,$sDefaultValue)
    Dim $sc
    $sc = CreateObject("ScriptControl")
    $sc.language = "VBScript"
    $inputbox = $sc.Eval('Inputbox("' + $sPrompt + '","' + $sTitle + '","' + $sDefaultValue + '")')
EndFunction

Top
#197067 - 2009-12-10 07:23 PM Re: Kixforms help [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Exactly - just be aware that in Allen's example, $Server will be empty if it was not a UNC path, and $Share will contain a drive letter.

I see that my explanation "elements (1)..." might be misleading - I avoided using square brackets in case they would conflict with the UBB formatting codes.

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

Top
#197070 - 2009-12-10 09:15 PM Re: Kixforms help [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
 Originally Posted By: Allen
Are you just looking for an input box? This little nugget was just recently posted:

 Code:
Function InputBox($sPrompt,Optional $sTitle,$sDefaultValue)
    Dim $sc
    $sc = CreateObject("ScriptControl")
    $sc.language = "VBScript"
    $inputbox = $sc.Eval('Inputbox("' + $sPrompt + '","' + $sTitle + '","' + $sDefaultValue + '")')
EndFunction

NICE! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.091 seconds in which 0.052 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