Setting a default value for argument type ".p-utf8"

Just starting out? Need help? Post your questions and find answers here.
hippy
User
User
Posts: 28
Joined: Tue Mar 05, 2013 3:11 pm

Setting a default value for argument type ".p-utf8"

Post by hippy »

Hi All,

Is it possible to set a default value in a prototype for an argument of type .p-utf8

Eg:

Code: Select all

PrototypeC ___igShowFontSelector_pr(label.p-utf8)  ; void igShowFontSelector(const char* label);
I'd like to do something like:

Code: Select all

PrototypeC ___igShowFontSelector_pr(label.p-utf8="Default Value")  ; void igShowFontSelector(const char* label);
But I cannot, I can with a .s but my library only supports UTF8, I only can do

Code: Select all

(label.p-utf8=0)
Cheers,
Hippy
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Setting a default value for argument type ".p-utf8"

Post by mk-soft »

Unfortunately not possible, because the parameter is a pointer to a UTF8 string at runtime and is released after the call.

If a features request...

Alternatively, check for null pointers in the function and use the default value.

Code: Select all

;-TOP

ProcedureC test(*UTF8_String)
  If *UTF8_String
    Debug PeekS(*UTF8_String, -1, #PB_UTF8)
  Else
    Debug "Default Value"
  EndIf
EndProcedure

; ----

PrototypeC externTest(label.p-utf8=0)

*CallTest.externTest = @test()

*CallTest()
*CallTest("Hello World")
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
hippy
User
User
Posts: 28
Joined: Tue Mar 05, 2013 3:11 pm

Re: Setting a default value for argument type ".p-utf8"

Post by hippy »

:( Thanks for the quick reply!
Post Reply