Source language: Translate to:

the dreaded file save double ext

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

the dreaded file save double ext

Postby schmutly » Sun Apr 12, 2009 7:31 pm

Hello.
After searching forum for 2 hours im still not able to find why when using
filesavebox i get the double extensions....
this seems to be what i want:
http://www.neosoftware.com/forum/viewto ... extensions but the link no longer works.

This is my code:
-----------------
FileSaveBox "Save" "*.php" "" "[File]"
SetVar "[File]" "[File].php"
If "[File]" ">" ""

FileWrite "[File]" "all" "[listfile]"

EndIf
-----------------
So saving myfile.php to itself i get a myfile.php.php doubled ext

Yes it may be answered somewhere else but after couple hours i see why i may need reading glasses...lol :D

Thanks anyone,
Robbie
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Postby bunker » Sun Apr 12, 2009 9:00 pm

Hi schmutly you have to control if the user already write the file extension.
Try this code:

Code: Select all
FileSaveBox "Save" "*.php" "" "[File]"
StrParse "[File]" "\" "[File_t]" "[File_c]"
SearchStr ".php" "[File_t[File_c]]" "[ext]" ""
if "[ext]" "=" "0"
   setvar "[File]" "[File].php"
endif
If "[File]" "<>" ""
   FileWrite "[File]" "All" "[listfile]"
EndIf


Greetings
User avatar
bunker
 
Posts: 141
Joined: Sat Sep 29, 2007 4:00 pm

Postby schmutly » Sun Apr 12, 2009 10:50 pm

Thanks for that dude :D

this line here:
SearchStr ".php" "[File_t[File_c]]" "[ext]" "" i had to remove the end "" as nothing to go into those, else it worked...i will look at this more closely,

Thanks again,

Robbie :D:D
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

I USE THIS...

Postby virger » Mon Apr 13, 2009 11:16 am

FileSaveBox "Save" "*.php" "" "[File]"


ExtractFileExt "[file]" "[ext]"

If "[File]" ">" ""

if "[ext]" "<>" "php"
StrReplace "[file]" "[ext]" "" "[file]" ""
endif
setvar "[ext]" "php"
FileWrite "[File].[ext]" "all" "[listfile]"

EndIf

PURA VIDA
FROM
COSTA RICA
AMERICA CENTRAL
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest