Question about auto Case correction feature

Working on new editor enhancements?
dige
Addict
Addict
Posts: 1405
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Question about auto Case correction feature

Post 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
"Daddy, I'll run faster, then it is not so far..."
Axolotl
Addict
Addict
Posts: 837
Joined: Wed Dec 31, 2008 3:36 pm

Re: Question about auto Case correction feature

Post 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.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Question about auto Case correction feature

Post 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.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Question about auto Case correction feature

Post 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": ""
;     }
; }


breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: Question about auto Case correction feature

Post 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.)
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Question about auto Case correction feature

Post 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
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
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Question about auto Case correction feature

Post 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
Post Reply