Page 1 of 1
Question about auto Case correction feature
Posted: Fri Nov 29, 2024 4:21 pm
by dige
Hi guys,
is there a possibility to deactivate the case correction in the editor section by section?
I would like to use this auto-correction and not deactivate it globally.
But I absolutely need the lower case for the following structure, as this is adopted by InsertJSONStructure().
What else can I do, that "data._data" will kept lower case?
Code: Select all
Structure _data
url.s
EndStructure
Structure _JSONResponse
data._data
success.b
status.i
EndStructure
Re: Question about auto Case correction feature
Posted: Fri Nov 29, 2024 4:48 pm
by Axolotl
I think it is the variable name "data " which is also a keyword in PB.
Maybe you can store the structure in a include file and use a differnt extension (e.g. .txt)
You can edit filename.txt in the ide and no auto correction should disturb you.
Re: Question about auto Case correction feature
Posted: Fri Nov 29, 2024 4:50 pm
by #NULL
Maybe with a macro of sorts
Code: Select all
Macro data_(ta=ta)
da#ta
EndMacro
Structure _data
url.s
EndStructure
Structure _JSONResponse
data_._data
success.b
status.i
EndStructure
In code you will still use data_ as the fieldname everywhere, but the actual fieldname should be data then, when serialized/exported or something like that.
<edit>
Not sure it really works, you might have to add the braces when using the macro.
Re: Question about auto Case correction feature
Posted: Fri Nov 29, 2024 4:58 pm
by #NULL
This one works
Code: Select all
Macro data_(ta=ta)
da#ta
EndMacro
Macro data_m
data_()
EndMacro
Structure _data
url.s
EndStructure
Structure _JSONResponse
data_m._data
success.b
status.i
EndStructure
j._JSONResponse
If CreateJSON(0)
InsertJSONStructure(JSONValue(0), @j, _JSONResponse)
Debug ComposeJSON(0, #PB_JSON_PrettyPrint)
EndIf
; {
; "status" : 0,
; "success": 0,
; "data" : {
; "url": ""
; }
; }
Re: Question about auto Case correction feature
Posted: Fri Nov 29, 2024 5:38 pm
by breeze4me
Your issue is similar to
this.
If the JSON data is only used within your program, the #PB_JSON_NoCase flag is fine.
For example, CreateJSON(#JSON, #PB_JSON_NoCase) and ParseJSON(#JSON, Input$ , #PB_JSON_NoCase).
However, if you need to interact with other case-sensitive programs, the macro is the only way to go.
a feature request:
The case correction feature should not be applied to field strings between 'Structure' and 'EndStructure'. (Keywords bolding and coloring as well.)
Re: Question about auto Case correction feature
Posted: Fri Nov 29, 2024 10:49 pm
by mk-soft
Ok ... solution at time
Add 'data' to Preferences -> Editor -> Coloring -> Custom keywords
Code: Select all
Structure _data
url.s
EndStructure
Structure _JSONResponse
data._data
success.b
status.i
EndStructure
DataSection
data.i 100
EndDataSection
Define json._JSONResponse
If CreateJSON(0)
InsertJSONStructure(JSONValue(0), @json, _JSONResponse)
Debug ComposeJSON(0, #PB_JSON_PrettyPrint)
EndIf
Re: Question about auto Case correction feature
Posted: Sat Nov 30, 2024 1:20 am
by BarryG
mk-soft wrote: Fri Nov 29, 2024 10:49 pmAdd 'data' to Preferences -> Editor -> Coloring -> Custom keywords
But:
dige wrote: Fri Nov 29, 2024 4:21 pmnot deactivate it globally