This usage of DEFAULT

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Red2
Posts: 273
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

This usage of DEFAULT

Post by Red2 »

Question: What exactly does "DEFAULT" do/mean in the following?

// SourceFiles, convert Array to String
DEFAULT acFiles TO HB_UCHAR( 0 )

In this example what does DEFAULT do to the (array) variable acFiles?
Unfortunately I have not found any explination of this usage in the HMG help file.

Thank you for your kind help!
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: This usage of DEFAULT

Post by AUGE_OHR »

hi,

if you pass a Parameter it is "expect" that it have a Value else it can crash

Code: Select all

FUNCTION Dummy(a)
? a    // -> crash when have no Value
i you have a "default" Value you must not pass Parameter

Code: Select all

#include "Common,ch"

FUNCTION Dummy(a)
   DEFAULT a TO "hello world"
? a    // -> does not crash
have fun
Jimmy
Red2
Posts: 273
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: This usage of DEFAULT

Post by Red2 »

Vielen Dank! I really appreciate your prompt and kind assistance.
Post Reply