View Full Version : cancel error
jackdaniels
03-23-2008, 10:20 AM
when i ccancel to load a page to web object it loads http://cancel/
this is the code i have on button click :File = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
Web.LoadURL("Web1", File[1]);
screwed over
03-23-2008, 01:07 PM
File = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
if File ~= "CANCEL" then
Web.LoadURL("Web1", File[1]);
end
that should fix it.
jackdaniels
03-23-2008, 03:43 PM
File = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
if File ~= "CANCEL" then
Web.LoadURL("Web1", File[1]);
end
that should fix it.
it didnt fix it !!!
jackdaniels
03-23-2008, 03:55 PM
this doesnt load cancel page but neither any hmtl page !!!
File = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.html)|*.html|(*.htm)|*.htm|", "", "dat", false, false);
if (File ~= "CANCEL") then else
Web.LoadURL("Web1", File[1]);
end
jassing
03-23-2008, 03:59 PM
File = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
if File ~= "CANCEL" then
Web.LoadURL("Web1", File[1]);
end
that should fix it.
Shouldn't it be
if File[1] ~= "CANCEL" then
jackdaniels
03-23-2008, 04:03 PM
thanks jassing thats it
ShadowUK
03-23-2008, 04:19 PM
Actually, the above examples are wrong, As in doing Dialog.FileBrowse and making the result variable "File". You are overriding a table, So doing File.DoesExsist, or anything else it would fail as you overrided a table created by AutoPlay Media Studio.
jassing
03-23-2008, 04:25 PM
Actually, the above examples are wrong, As in doing Dialog.FileBrowse and making the result variable "File". You are overriding a table, So doing File.DoesExsist, or anything else it would fail as you overrided a table created by AutoPlay Media Studio.
GOOD CATCH! I'm embarassed that I didn't pick up on it...
I always use bastardized hungarian notation for my vars.
cVariable = String/Text
tVariable = table
nVariable = number/integer
bVariable = Logical/boolean
Ultimately; I find it easier to follow later down the line in a complex script -- and I don't run the risk of doing exactly what you pointed out.
ShadowUK
03-23-2008, 04:45 PM
I do:
sString
fFunction
bBoolean
tTable
Etc.
jackdaniels
03-23-2008, 04:45 PM
can u give me a better code than i have ? well i just want to load html and htm files...
jassing
03-23-2008, 04:51 PM
I do:
sString
fFunction
bBoolean
tTable
Etc.
Same Idea -- with one exception -- for my functions (I'd say better than 90% of them) I "integrate" them into existing objects or create new ones.
For instance, I have a function that returns just the filename ("file.ext") of a full path name (c:\program files\appdir\file.exe) -- that is called:
File.NameOnly()
that, I think, makes it very obvious; for new things; I just create the object itself.
-josh
jackdaniels
03-23-2008, 04:53 PM
Same Idea -- with one exception -- for my functions (I'd say better than 90% of them) I "integrate" them into existing objects or create new ones.
For instance, I have a function that returns just the filename ("file.ext") of a full path name (c:\program files\appdir\file.exe) -- that is called:
File.NameOnly()
that, I think, makes it very obvious; for new things; I just create the object itself.
-josh
can u give an example of File.Nameonly() ?
jassing
03-23-2008, 05:01 PM
can u give an example of File.Nameonly() ?
function File.NameOnly( cFile )
local tFile = String.SplitPath( cFile );
return tFile.Filename .. tFile.Extension;
end
ShadowUK
03-23-2008, 05:07 PM
Or then again :P
01 function File.GetName(sFile)
02 return String.SplitPath(sFile).Filename..String.SplitPath (sFile).Extension
03 end
Intrigued
03-23-2008, 05:22 PM
And if you really want to take it out all the way... you may include one of these versions of the function into a .lua file say .. called constants.lua and then drag-n-drop it onto the default page, for example, in your AMS project. Then the constants you have in that file are accessible throughout the entire project.
jassing
03-23-2008, 05:31 PM
Or then again :P
01 function File.GetName(sFile)
02 return String.SplitPath(sFile).Filename..String.SplitPath (sFile).Extension
03 end
My original verson was like that; but clients found it harder to read/understand. I also did some speed tests....guess which was faster? ;-)
In various speed tests (when something ran slow that I didn't think should) I ran some speed tests -- A general rule of thumb I've found is to reduce calls to methods/properties. In your case it makes 2 calls to my 1. While for a one call you won't notice a difference, but if your'e making the call on a list of 10,000 file names you will....
the LUA engine IR uses seems to be effecient in memory management; so creating variables doesn't eat up memory and makes code (IMHO) much more readable.
For everything in life, there will be a few dozen ways to do something; like motorcycles -- there's different styles to suit every rider; doesn't mean one is better than the other... Your style is effecient in low memory conditions; mine (again IMHO) is effecient in speed & readablility.
-josh
Intrigued
03-23-2008, 05:37 PM
Ah, interesting Jassing. Something for us all to keep in mind, when performance becomes paramont.
Thanks,
screwed over
03-23-2008, 07:54 PM
wFile = Dialog.FileBrowse(true, "Open HTML File", _DesktopFolder, "HTML Files (*.html, *.htm)|*.htm;*.html|", "", "html", false, false);
if wFile[1] ~= "CANCEL" and wFile ~= nil then
Web.LoadURL("Web1", wFile[1]);
end
this is pretty much the same as jassings but will only let the user select *.htm and *.html files. as well as checking incase you get a nil value (you shouldnt but it has happened to me before). plus it doesnt overwrite APMS built in "File" tables like jassings. =P
jassing
03-23-2008, 08:02 PM
built in "File" tables like jassings. =P
Screwed:
That wasn't my code -- it was yours. ;-)
All I pointed out was that you needed to address it as an array/table....
screwed over
03-23-2008, 08:04 PM
was it? its like 1 in the morning so im not really paying attention.
either way, it doesnt overwrite the built in tables
jassing
03-23-2008, 08:12 PM
was it? its like 1 in the morning so im not really paying attention.
yea; I hear ya! Where ya located?
either way, it doesnt overwrite the built in tables
That was a good catch -- i was embarassed that I didn't... I spent a day trying to fix a clients installer (I was not the original author) until I caught that they had overwritten the String object, indirectly...
I wish the LUA Editor would say "Are you sure you want to overwrite the built in object?"
I have, for my 64 bit registry support, intentionally overwriten the Registry object to avoid having to change references everywhere -- so being able to do it can be benificial...
screwed over
03-23-2008, 10:13 PM
i'm in england. i know what ya mean by that, i've once completley overwritten the built in label functions in apms before. i dont even know how i did that but it was a pain, had to rewrite over half of my scripts to fix it.
rexzooly
03-23-2008, 10:22 PM
i'm in england. i know what ya mean by that, i've once completley overwritten the built in label functions in apms before. i dont even know how i did that but it was a pain, had to rewrite over half of my scripts to fix it.
i think its becusae AMS use custom lables to start with maybe i am wrong
but AMS is way simpler then lua its self so something had to be done to make
the fuctions easyer maybe? i don't know just going out on a wim here.
jassing
03-23-2008, 10:34 PM
i think its becusae AMS use custom lables to start with maybe i am wrong
but AMS is way simpler then lua its self so something had to be done to make
the fuctions easyer maybe? i don't know just going out on a wim here.
What do you mean "so something had to be done to make the functions easyer maybe"?
AMS isn't simple by any means -- it's actually a fairly robust RAD environment -- not full blown applications; but it's definately strong.
LUA wouldn't have been my 1st choice; but it just adds to the strength of the product -- lua is flexible and robust.
I don't get (or understand) your point.
jassing
03-23-2008, 10:35 PM
i'm in england. i know what ya mean by that, i've once completley overwritten the built in label functions in apms before. i dont even know how i did that but it was a pain, had to rewrite over half of my scripts to fix it.
I'm on the west coast of the USA on a small island....
Cheers
-josh
rexzooly
03-23-2008, 10:38 PM
What do you mean "so something had to be done to make the functions easyer maybe"?
AMS isn't simple by any means -- it's actually a fairly robust RAD environment -- not full blown applications; but it's definately strong.
LUA wouldn't have been my 1st choice; but it just adds to the strength of the product -- lua is flexible and robust.
I don't get (or understand) your point.
woow there feller i didn't mean anything but AMS makes lua much more
easyer to handle ues i agree its robust i love it so much i moved all my learing
from VB,C++ and all that side to Lua as i liked what i saw.
please don't take what i said in anyway asgest lua :)
GoOgLe
03-24-2008, 02:28 AM
it doesnt split the path !!
myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);
Folder.Create(myDocsFolder.."\\Addons");
tblMenu = Application.GetMenu();
local nNewitem = Table.Count(tblMenu)+1;
tblMenu[nNewitem] ={};
tblMenu[nNewitem].Text = "&Addons";
tblMenu[nNewitem].ID = 1000;
tblMenu[nNewitem].Checked = false;
tblMenu[nNewitem].Enabled = true;
tblMenu[nNewitem].SubMenu = {};
local tFiles = File.Find(myDocsFolder.."\\Addons", "*.exe");
function File.GetName(sFile)
return String.SplitPath(sFile).Filename..String.SplitPath (sFile).Extension
end
if (tFiles) then
local x = 0;
for x = 1,Table.Count(tFiles) do
tblMenu[nNewitem].SubMenu[x] = {};
tblMenu[nNewitem].SubMenu[x].Text = tFiles[x];
tblMenu[nNewitem].SubMenu[x].ID = 1000+x;
tblMenu[nNewitem].SubMenu[x].Checked = false;
tblMenu[nNewitem].SubMenu[x].Enabled = true;
end
Application.SetMenu(tblMenu);
else
end
jassing
03-24-2008, 10:20 AM
google:
put the function declaration in "global functions" or a script file.
You can't put a function declaration inline with code.
Then you need to call it so you can split it.
it does work; you're just not understanding the concepts.
jassing
03-24-2008, 10:21 AM
woow there feller i didn't mean anything but AMS makes lua much more
easyer to handle ues i agree its robust i love it so much i moved all my learing
from VB,C++ and all that side to Lua as i liked what i saw.
please don't take what i said in anyway asgest lua :)
Must be a language thing then; becuase I don't understand your comment at all then. Sorry.
-josh
RizlaUK
03-24-2008, 10:29 AM
I'm on the west coast of the USA on a small island....
sounds nice, im in the heart of this concreate jungle called "London", the place everyone loves to visit, but hates to live in....the only island round here is a traffic island, lol
it does work; you're just not understanding the concepts.
usually the case,time spent reading can save time spent posting.......
jassing
03-24-2008, 10:46 AM
sounds nice, im in the heart of this concreate jungle called "London", the place everyone loves to visit, but hates to live in....the only island round here is a traffic island, lol
I used to live in San Francisco and San Diego -- I've realized that I don't like crowds -- I'm bummed someone built a house boarding my lot.. I don't know how you do it --- but then again; England is an island ;-)
usually the case,time spent reading can save time spent posting.......
It's always hard to balance the desire to help; and the need not to do someone elses work 100% -- to learn; you have to want to understand; but sometimes, language is also very hard barrier....
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.