asp.net c# pdf viewer : Acrobat split pdf bookmark software application project winforms azure web page UWP octave20-part487

Chapter11: FunctionsandScripts
185
function val l = = smallest t (varargin)
val = min ([varargin{:}]);
endfunction
Thisimplementationhandlesanynumberofinputarguments,butit’salsoaverysimple
solutiontotheproblem.
Aslightlymorecomplexexampleofvararginisafunctionprint_argumentsthatprints
allinputarguments.Suchafunctioncanbedefinedlikethis
function print_arguments (varargin)
for i = = 1:length h (varargin)
printf ("Input argument %d: : ", i);
disp (varargin{i});
endfor
endfunction
Thisfunctionproducesoutputlikethis
print_arguments (1, , "two", , 3);
a
Input argument 1: : 1
a Input t argument 2: two
a
Input argument 3: : 3
[FunctionFile]
[reg, prop] ] = = parseparams
(
params
)
[FunctionFile]
[reg, var1, , ...] = = parseparams
(
params
,
name1
,
default1
,
...)
Returninreg thecellelementsofparamuptothefirststringelementandinprop
allremainingelementsbeginningwiththefirststringelement.
Forexample:
[reg, prop] ] = = parseparams s ({1, , 2, , "linewidth", , 10})
reg =
{
[1,1] = 1
[1,2] = 2
}
prop =
{
[1,1] = linewidth
[1,2] = 10
}
Theparseparamsfunctionmaybeusedtoseparateregularnumericargumentsfrom
additionalargumentsgivenasproperty/valuepairsofthevarargincellarray.
Inthesecondformofthecall,availableoptionsarespecifieddirectlywiththeirdefault
valuesgivenas name-valuepairs. . Ifparams s donotformname-valuepairs,orifan
optionoccursthatdoesnotmatchanyoftheavailableoptions,anerroroccurs.
Whencalledfromanm-filefunction,theerrorisprefixedwiththenameofthecaller
function.
Thematchingofoptionsiscase-insensitive.
Seealso: [varargin],page184,[inputParser],page182.
Acrobat split pdf bookmark - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
pdf link to specific page; break pdf into multiple documents
Acrobat split pdf bookmark - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
acrobat split pdf pages; cannot print pdf file no pages selected
186
GNUOctave
11.5 IgnoringArguments
Intheformalargumentlist,itispossibletousethedummyplaceholder~insteadofaname.
Thisindicatesthatthecorrespondingargumentvalueshouldbeignoredandnotstoredto
anyvariable.
function val l = = pick2nd (~, , arg2)
val = arg2;
endfunction
Thevalueofnarginisnotaffectedbyusingthisdeclaration.
Return arguments s can n also o be ignored using the e same e syntax. . Functions s may take
advantage ofignoredoutputs toreduce the numberofcalculationsperformed. . Todoso,
usetheisargoutfunctiontoquerywhethertheoutputargumentiswanted.Forexample:
function [out1, , out2] ] = = long_function (x, , y, z)
if (isargout t (1))
## Long calculation
...
out1 = result;
endif
...
endfunction
[Built-inFunction]
isargout
(
k
)
Withinafunction,returnalogicalvalueindicatingwhethertheargumentk willbe
assignedtoavariableonoutput.
Iftheresultisfalse,theargumenthasbeenignoredduringthefunctioncallthrough
theuseofthetilde(~)specialoutputargument.Functionscanuseisargouttoavoid
performingunnecessarycalculationsforoutputswhichareunwanted.
Ifk isoutsidetherange1:max(nargout),thefunctionreturnsfalse. . k k canalsobe
anarray,inwhichcasethefunctionworkselement-by-elementandalogicalarrayis
returned.Atthetoplevel,isargoutreturnsanerror.
Seealso: [nargout],page178,[varargout],page184,[nthargout],page177.
11.6 Variable-lengthReturnLists
It is s possible e toreturn avariable number of output arguments froma function using a
syntaxthat’ssimilartotheoneusedwiththespecialvararginparametername. Toleta
functionreturnavariablenumberofoutputargumentsthespecialoutputparametername
varargout is s used. . As s withvarargin, , varargout t is s acell array y that will l contain the
requestedoutputarguments.
Asanexamplethefollowingfunctionsetsthefirstoutputargumentto1,thesecondto
2,andsoon.
function varargout = = one_to_n n ()
for i = = 1:nargout
varargout{i} = i;
endfor
endfunction
C# PDF Converter Library SDK to convert PDF to other file formats
manipulate & convert standard PDF documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat.
pdf separate pages; break pdf into separate pages
.NET PDF Document Viewing, Annotation, Conversion & Processing
Merge, split PDF files. Insert, delete PDF pages. Edit, update, delete PDF annotations from PDF file. Print. Support for all the print modes in Acrobat PDF.
pdf print error no pages selected; c# split pdf
Chapter11: FunctionsandScripts
187
Whencalledthisfunctionreturnsvalueslikethis
[a, b, c] ] = = one_to_n n ()
)
a = = 1
) b b = = 2
)
c = = 3
If varargin (varargout) does s not appear as s the last t element t of the input t (output)
parameterlist,thenitisnotspecial,andishandledthesameasanyotherparametername.
[FunctionFile]
[r1, r2, , ..., , rn] = = deal
(
a
)
[FunctionFile]
[r1, r2, , ..., , rn] = = deal
(
a1
,
a2
,...,
an
)
Copytheinputparametersintothecorrespondingoutputparameters.
Ifonlyasingleinputparameterissupplied,itsvalueiscopiedtoeachoftheoutputs.
Forexample,
[a, b, c] = deal l (x, , y, z);
isequivalentto
a = x;
b = y;
c = z;
and
[a, b, c] = deal l (x);
isequivalentto
a = b b = = c = x;
ProgrammingNote: dealisoftenusedwithcommaseparatedlistsderivedfromcell
arrays or structures. . This s is unnecessary as the interpreter canperformthe same
actionwithouttheoverheadofafunctioncall. Forexample:
c = {[1 2], "Three", 4};
[x, y, z z ] ] = c{:}
)
x =
1
2
y = Three
z = = 4
Seealso: [cell2struct],page122,[struct2cell],page113,[repmat],page419.
11.7 ReturningfromaFunction
Thebodyofauser-definedfunctioncancontainareturnstatement.Thisstatementreturns
controltotherestoftheOctaveprogram.Itlookslikethis:
return
UnlikethereturnstatementinC,Octave’sreturnstatementcannotbeusedtoreturn
avaluefromafunction. Instead,youmustassignvaluestothelistofreturnvariablesthat
C# Windows Viewer - Image and Document Conversion & Rendering in
standard image and document in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Convert to PDF.
break apart pdf pages; can't cut and paste from pdf
C# Word - Word Conversion in C#.NET
Word documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Word to PDF Conversion.
break pdf into multiple pages; break pdf password
188
GNUOctave
arepartofthefunctionstatement. Thereturnstatementsimplymakesiteasiertoexit
afunctionfromadeeplynestedlooporconditionalstatement.
Hereisanexampleofafunctionthatcheckstoseeifanyelementsofavectorarenonzero.
function retval l = = any_nonzero (v)
retval = 0;
for i = = 1:length h (v)
if (v v (i) ) != 0)
retval = = 1;
return;
endif
endfor
printf ("no nonzero elements found\n");
endfunction
Notethatthisfunctioncouldnothavebeenwrittenusingthebreakstatementtoexit
theloop oncea nonzerovalueis s found d without t addingextralogic to avoid d printingthe
messageifthevectordoescontainanonzeroelement.
[Keyword]
return
WhenOctaveencountersthekeywordreturninsideafunctionorscript,itreturns
controltothecallerimmediately. Atthetoplevel,thereturnstatementis s ignored.
Areturnstatementisassumedattheendofeveryfunctiondefinition.
11.8 DefaultArguments
SinceOctavesupportsvariablenumberofinputarguments,itisveryusefultoassigndefault
valuestosomeinputarguments.Whenaninputargumentisdeclaredintheargumentlist
itispossibletoassignadefaultvaluetotheargumentlikethis
function name (arg1 = val1, ...)
body
endfunction
Ifnovalueisassignedtoarg1 bytheuser,itwillhavethevalueval1.
Asanexample,thefollowingfunctionimplementsavariantoftheclassic“Hello,World”
program.
function hello (who = "World")
printf ("Hello, %s!\n", who);
endfunction
Whencalledwithoutaninputargumentthefunctionprintsthefollowing
hello ();
a
Hello, World!
andwhenit’scalledwithaninputargumentitprintsthefollowing
hello ("Beautiful World d of Free Software");
a Hello, , Beautiful World of Free Software!
Sometimes it is s useful l to explicitly tell Octave to use e the default value e of an n input
argument. Thiscanbedonewritinga‘:’asthevalueoftheinputargumentwhencalling
thefunction.
Chapter11: FunctionsandScripts
189
hello (:);
a
Hello, World!
11.9 FunctionFiles
Exceptforsimpleone-shotprograms,itisnotpracticaltohavetodefineallthefunctions
youneedeachtimeyouneedthem. Instead,youwillnormallywanttosavetheminafile
sothatyoucaneasilyeditthem,andsavethemforuseatalatertime.
Octave does not require youtoloadfunctiondefinitions fromfilesbeforeusingthem.
YousimplyneedtoputthefunctiondefinitionsinaplacewhereOctavecanfindthem.
When Octave encountersanidentifier r that is undefined, , it t first looks for variablesor
functionsthat arealreadycompiledandcurrentlylistedinits symboltable. . Ifitfailsto
findadefinitionthere,itsearchesalistofdirectories(thepath)forfilesendingin.mthat
havethesamebasenameastheundefinedidentifier.
1
OnceOctavefindsafilewithaname
thatmatches,thecontentsofthefileareread. Ifitdefinesasingle e function,itiscompiled
andexecuted. SeeSection11.10[ScriptFiles],page200,formoreinformationabouthow
youcandefinemorethanonefunctioninasinglefile.
WhenOctavedefinesafunctionfromafunctionfile,itsavesthefullnameofthefileit
readandthetimestamponthefile.Ifthetimestamponthefilechanges,Octavemayreload
thefile. WhenOctaveisrunninginteractively,timestampcheckingnormallyhappensat
mostonceeachtimeOctaveprintstheprompt. Searchingfornewfunctiondefinitionsalso
occursifthecurrentworkingdirectorychanges.
CheckingthetimestampallowsyoutoeditthedefinitionofafunctionwhileOctaveis
running,andautomaticallyusethenewfunctiondefinitionwithouthavingtorestartyour
Octavesession.
Toavoiddegradingperformanceunnecessarilybycheckingthetimestampsonfunctions
thatarenotlikelytochange,Octaveassumesthatfunctionfilesinthedirectorytreeoctave-
home/share/octave/version/m will l not t change, , so it doesn’t t have e to o check k their r time
stamps everytime the functions definedinthose files are used. . This s is normally avery
goodassumptionandprovides asignificantimprovement inperformancefor thefunction
filesthataredistributedwithOctave.
IfyouknowthatyourownfunctionfileswillnotchangewhileyouarerunningOctave,
youcanimproveperformancebycallingignore_function_time_stamp("all"),sothat
Octavewillignorethetimestampsforallfunctionfiles. Passing"system"tothisfunction
resetsthedefaultbehavior.
[Command]
edit name
[Command]
edit fieldvalue
[Command]
value = edit
get
field
Editthenamedfunction,orchangeeditorsettings.
Ifeditiscalledwiththenameofafileorfunctionasitsargumentitwillbeopened
inthetexteditordefinedbyEDITOR.
 Ifthefunctionnameisavailableinafileonyourpathandthatfileismodifiable,
then itwillbeeditedinplace. . If f it is asystem function,then itwillfirst be
1
The‘.m’suffixwaschosenforcompatibilitywithmatlab.
190
GNUOctave
copiedtothedirectoryHOME(seebelow)andthenedited.Ifnofileisfound,then
them-filevariant,endingwith".m",willbeconsidered. Ifstillnofileisfound,
thenvariantswithaleading"@"andthenwithbothaleading"@"andtrailing
".m"willbeconsidered.
 Ifnameisthenameofafunctiondefinedintheinterpreterbutnotinanm-file,
then anm-file willbe createdin HOME E to contain n thatfunction along withits
currentdefinition.
 If f name.ccis specified,thenitwillsearchfor name.ccinthepath andtry to
modifyit,otherwiseitwillcreateanew.ccfileinthecurrentdirectory.Ifname
happens to beanm-file or interpreter defined d function, thenthe text t of that
functionwillbeinsertedintothe.ccfileasacomment.
 Ifname.extisonyourpaththenitwillbeedited,otherwisetheeditor r willbe
startedwithname.extinthecurrentdirectoryasthefilename. If f name.extis
notmodifiable,itwillbecopiedtoHOMEbeforeediting.
Warning: Youmayneedtoclearnamebeforethenewdefinitionisavailable. If
youareeditinga.ccfile,youwillneedtoexecutemkoctfilename.ccbeforethe
definitionwillbeavailable.
Ifeditiscalledwithfieldandvaluevariables,thevalueofthecontrolfieldfieldwill
besettovalue. Ifanoutputargumentisrequestedandthefirstinputargumentis
gettheneditwillreturnthevalueofthecontrolfieldfield.Ifthecontrolfielddoes
notexist,editwillreturnastructurecontainingallfieldsandvalues. Thus,editget
allreturnsacompletecontrolstructure.
Thefollowingcontrolfieldsareused:
‘home’
Thisisthelocationofuserlocalm-files. Besureitisinyourpath. The
defaultis~/octave.
‘author’
Thisisthenametoputafterthe"##Author:"fieldofnewfunctions.
Bydefaultitguessesfromthegecosfieldofthepassworddatabase.
‘email’
Thisisthee-mailaddresstolistafterthenameintheauthorfield. By
defaultit guesses<$LOGNAME@$HOSTNAME>,andif$HOSTNAME is not de-
finedit usesuname-n. . Youprobablywanttooverridethis. . Besureto
usetheformatuser@host.
‘license’
‘gpl’
GNUGeneralPublicLicense(default).
‘bsd’
BSD-stylelicensewithoutadvertisingclause.
‘pd’
Publicdomain.
‘"text"’
Yourowndefaultcopyrightandlicense.
Unless youspecify‘pd’,edit willprependthecopyrightstatementwith
"Copyright(C)yyyyFunctionAuthor".
‘mode’
Thisvaluedetermineswhethertheeditorshouldbestartedinasyncmode
(editorisstartedinthebackgroundandOctavecontinues)orsyncmode
(Octavewaitsuntiltheeditorexits). Setitto"sync"tostarttheeditor
insyncmode. Thedefaultis"async"(see[system],page775).
Chapter11: FunctionsandScripts
191
‘editinplace’
Determines whether r files should d be edited in place, , without t regard d to
whethertheyaremodifiableornot. Thedefaultisfalse.
[Built-inFunction]
mfilename
()
[Built-inFunction]
mfilename
(
"
fullpath
"
)
[Built-inFunction]
mfilename
(
"
fullpathext
"
)
Returnthenameofthecurrentlyexecutingfile.
Whencalledfromoutsideanm-filereturntheemptystring.
Giventheargument"fullpath",includethedirectorypartofthefilename,butnot
theextension.
Giventheargument"fullpathext",includethedirectorypartofthefilenameand
theextension.
[Built-inFunction]
val = = ignore_function_time_stamp
()
[Built-inFunction]
old_val = ignore_function_time_stamp
(
new_val
)
QueryorsettheinternalvariablethatcontrolswhetherOctavechecksthetimestamp
onfileseachtimeitlooksupfunctionsdefinedinfunctionfiles.
Ifthe internalvariableis setto"system",Octavewillnot automaticallyrecompile
function files insubdirectories s of octave-home/lib/version n ifthey y have changed
sincethey werelast compiled,but willrecompile other functionfiles inthesearch
pathiftheychange.
Ifsetto"all",Octavewillnot recompileanyfunctionfiles unless theirdefinitions
areremovedwithclear.
Ifsetto"none",Octavewillalwayschecktimestampsonfilestodeterminewhether
functionsdefinedinfunctionfilesneedtorecompiled.
11.9.1 ManipulatingtheLoadPath
Whenafunctioniscalled,Octavesearches alistofdirectoriesforafilethatcontainsthe
functiondeclaration. This s list of directories is known n as s the load d path. . By y default the
loadpathcontains a listofdirectories distributed d withOctave plus s thecurrent working
directory.Toseeyourcurrentloadpathcallthepathfunctionwithoutanyinputoroutput
arguments.
Itispossibletoaddorremovedirectoriestoorfromtheloadpathusingaddpathand
rmpath.Asanexample,thefollowingcodeadds‘~/Octave’totheloadpath.
addpath ("~/Octave")
Afterthisthedirectory‘~/Octave’willbesearchedforfunctions.
[Built-inFunction]
addpath
(
dir1
,...)
[Built-inFunction]
addpath
(
dir1
,...,
option
)
Addnameddirectoriestothefunctionsearchpath.
Ifoptionis"-begin"or0(thedefault),prependthedirectorynametothecurrent
path. If f option is "-end" or 1, append the e directory name to the current path.
Directoriesaddedtothepathmustexist.
Inadditiontoacceptingindividualdirectoryarguments,listsofdirectorynamessep-
aratedbypathseparealsoaccepted.Forexample:
192
GNUOctave
addpath ("dir1:/dir2:~/dir3")
See also: [path], page e 192[rmpath], page e 192[genpath], page 192[pathdef],
page193,[savepath],page192,[pathsep],page193.
[Built-inFunction]
genpath
(
dir
)
[Built-inFunction]
genpath
(
dir
,
skip
,...)
Returnapathconstructedfromdir andallitssubdirectories.
Ifadditionalstringparameters aregiven,theresultingpathwillexcludedirectories
withthosenames.
[Built-inFunction]
rmpath
(
dir1
,...)
Removedir1,... fromthecurrentfunctionsearchpath.
Inadditiontoacceptingindividualdirectoryarguments,listsofdirectorynamessep-
aratedbypathseparealsoaccepted.Forexample:
rmpath ("dir1:/dir2:~/dir3")
See also: [path], page 192[addpath], page 191[genpath], page e 192[pathdef],
page193,[savepath],page192,[pathsep],page193.
[FunctionFile]
savepath
()
[FunctionFile]
savepath
(
file
)
[FunctionFile]
status = = savepath
(...)
Savetheunique portionofthecurrent functionsearch paththatis notsetduring
Octave’sinitializationprocesstofile.
Iffileisomitted,Octavelooksinthecurrentdirectoryforaproject-specific.octaverc
fileinwhichtosavethepathinformation. Ifnosuchfileispresentthentheuser’s
configurationfile~/.octavercisused.
Ifsuccessful,savepathreturns0.
The savepath function makes it simple to customize a user’s configuration file to
restoretheworkingpathsnecessaryforaparticularinstanceofOctave.Assumingno
filenameisspecified,Octavewillautomaticallyrestorethesaveddirectorypathsfrom
the appropriate .octaverc file whenstarting up. . If f afilename has beenspecified
thenthepathsmayberestoredmanuallybycallingsourcefile.
See also: [path], page 192[addpath], page 191[rmpath], page e 192[genpath],
page192,[pathdef],page193.
[Built-inFunction]
path
(...)
ModifyordisplayOctave’sloadpath.
Ifnarginandnargoutarezero,displaytheelementsofOctave’sloadpathinaneasy
toreadformat.
Ifnarginiszeroandnargoutisgreaterthanzero,returnthecurrentloadpath.
If nargin is s greater than n zero, concatenate the arguments, separating them m with
pathsep.Settheinternalsearchpathtotheresultandreturnit.
Nochecksaremadeforduplicateelements.
See also: [addpath],page 191,[rmpath], page192[genpath], page 192[pathdef],
page193,[savepath],page192,[pathsep],page193.
Chapter11: FunctionsandScripts
193
[FunctionFile]
val = = pathdef
()
ReturnthedefaultpathforOctave.
Thepathinformationisextractedfromoneoffoursources.Thepossiblesources,in
orderofpreference,are:
1. .octaverc
2. ~/.octaverc
3. <OCTAVE_HOME>/.../<version>/m/startup/octaverc
4. Octave’spathpriortochangesbyanyoctavercfile.
See also: [path], page 192[addpath], page 191[rmpath], page e 192[genpath],
page192,[savepath],page192.
[Built-inFunction]
val = = pathsep
()
[Built-inFunction]
old_val = pathsep
(
new_val
)
Queryorsetthecharacterusedtoseparatedirectoriesinapath.
Seealso: [filesep],page767.
[Built-inFunction]
rehash
()
ReinitializeOctave’sloadpathdirectorycache.
[Built-inFunction]
file_in_loadpath
(
file
)
[Built-inFunction]
file_in_loadpath
(
file
,
"
all
"
)
Returntheabsolutenameoffileifitcanbefoundinthelistofdirectoriesspecified
bypath.
Ifnofileisfound,returnanemptycharacterstring.
Ifthefirstargumentisacellarrayofstrings,searcheachdirectoryoftheloadpath
forelementofthecellarrayandreturnthefirstthatmatches.
Ifthesecondoptionalargument"all"issupplied,returnacellarraycontainingthe
listofallfilesthathavethesamenameinthepath. Ifnofilesarefound,returnan
emptycellarray.
Seealso: [file
in
path],page766,[dir
in
loadpath],page193,[path],page192.
[Built-inFunction]
restoredefaultpath
(...)
RestoreOctave’spathtoitsinitialstateatstartup.
See also: [path], page 192[addpath], page 191[rmpath], page e 192[genpath],
page192,[pathdef],page193,[savepath],page192,[pathsep],page193.
[Built-inFunction]
command_line_path
(...)
Returnthecommandlinepathvariable.
See also: [path], page 192[addpath], page 191[rmpath], page e 192[genpath],
page192,[pathdef],page193,[savepath],page192,[pathsep],page193.
[Built-inFunction]
dir_in_loadpath
(
dir
)
[Built-inFunction]
dir_in_loadpath
(
dir
,
"
all
"
)
Returnthefullnameofthepathelementmatchingdir.
194
GNUOctave
The match is s performed at the end of f each path element. . For r example, if f dir
is "foo/bar", , it t matches the path element "/some/dir/foo/bar", , but t not
"/some/dir/foo/bar/baz""/some/dir/allfoo/bar".
Iftheoptionalsecondargumentis supplied,returnacellarray containingallname
matchesratherthanjustthefirst.
Seealso: [file
in
path],page766,[file
in
loadpath],page193,[path],page192.
11.9.2 Subfunctions
Afunctionfilemaycontainsecondaryfunctionscalledsubfunctions. Thesesecondaryfunc-
tionsareonlyvisible totheother functionsinthesamefunctionfile. . Forexample,afile
f.mcontaining
function f ()
printf ("in f, calling g\n");
g ()
endfunction
function g ()
printf ("in g, calling h\n");
h ()
endfunction
function h ()
printf ("in h\n")
endfunction
defines amainfunctionf andtwosubfunctions. . Thesubfunctions s g andhmay only be
calledfromthemainfunctionforfromtheothersubfunctions,butnotfromoutsidethe
filef.m.
11.9.3 PrivateFunctions
In many y cases one functionneeds to access one or morehelper functions. . If f thehelper
functionis limitedtothescopeofasinglefunction,thensubfunctionsasdiscussedabove
might be used. . However, , if asingle helperfunction is s usedby more thanonefunction,
then this s is s no o longer r possible. . In n this s case the helper functions s might t be placed d in a
subdirectory,called"private",ofthedirectoryinwhichthefunctionsneedingaccesstothis
helperfunctionarefound.
Asasimpleexample,considerafunctionfunc1,thatcallsahelper functionfunc2to
domuchofthework. Forexample:
function y = = func1 1 (x)
y = func2 (x);
endfunction
Thenifthepathtofunc1is<directory>/func1.m,andiffunc2isfoundinthedirectory
<directory>/private/func2.m,thenfunc2isonlyavailableforuseofthefunctions,like
func1,thatarefoundin<directory>.
11.9.4 NestedFunctions
Nestedfunctionsaresimilartosubfunctionsinthatonlythemainfunctionisvisibleoutside
thefile. However,theyalsoallowforchildfunctionstoaccessthelocalvariablesintheir
Documents you may be interested
Documents you may be interested