Page 1 of 1

Curiosity: rules for spaces around \ in vars with structures

Posted: Thu Jan 02, 2025 6:34 am
by Thumper
Not a real problem here as this is so easily solved but has me curious what the rules are.

I have something like "scriptDetails \ oneTouch04" and I like to surrounding symbols with spaces for readability. This usually is fine but there are times it requires removing the spaces to make it "script\oneTouch04".

Here is one specific example generating an error on the \text1 (.s in the structure) line storing the string: "Can't write a numerical value into a string variable". Removing the spaces fixes the error. I left a few extra lines to show how the other places do not generate an error. (BTW, I love the "with" command!)

Code: Select all

     with wEditor\onetouch07
          \id = canvasGadget ( #pb_any, x2, y3, wFF, h3 )
          \text1 = scriptDetails \ oneTouch07
          \align = #myButton_alignleft
          \type = #myButton_player
          \style = #myButton_themeColors
     endWith
     enableGadgetDrop ( wEditor \ onetouch07 \ id, #pb_drop_private, #pb_drag_copy | #pb_drag_move | #pb_drag_link, 1 )
     drawButton      ( @wEditor \ onetouch07 )

     y3 = y3 + h3 + h4
Elsewhere the space is accepted just fine:

Code: Select all

     procedure pbpp_g_wEditor_onetouch04 ( event.i )
          select event
               case #pb_event_gadgetDrop
                    scriptDetails \ oneTouch04 = stringField ( dragAndDrop, 1, "|" )
                    wEditor \ onetouch04 \ text1 = scriptDetails \ oneTouch04
                    drawButton ( @wEditor \ oneTouch04 )
                    dragAndDrop = ""
                    dragAndDropSource = 0
          endSelect
     endProcedure
as does

Code: Select all

     writeStringN ( handle, "ONETOUCH05" + chr(9) + scriptDetails \ oneTouch05 )
Anyhow, just a curiosity. I just use the spaces per habit and remove them when the compiler barks.

Cheers