Hot Topic (More than 10 Replies) Syntax shortcut (Read 1774 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Syntax shortcut
Nov 16th, 2007 at 7:02pm
Print Post Print Post  
What's the syntax shortcut for adding a string to itself?  For example, I have the following code:
Code
Select All
Fork_Info = Fork_1 + s5spaces + vF1TotalString + @NewLine() 


I then continue to add stuff to Fork_Info depending on the outcome of tests.  The syntax I'm looking for is the way to bypass having to repeat "Fork_Info = Fork_Info + ..."

Thanks in advance.
  

**
Captain Infinity
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: Syntax shortcut
Reply #1 - Nov 16th, 2007 at 7:07pm
Print Post Print Post  
Have you tried:
Fork_Info += "..."
  
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Syntax shortcut
Reply #2 - Nov 16th, 2007 at 7:10pm
Print Post Print Post  
Thanks Ben!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Syntax shortcut
Reply #3 - Nov 16th, 2007 at 7:14pm
Print Post Print Post  
Scott,

This shortcut is deprecated. It is not really part of SBasic and is not reliable when used with strings. That it works at all is coincidental, not intentional. That's why 2.0's documentation does not include it. It's really not worth a couple of keystrokes to rely on something that only works by coincidence. I recommend you use the explicit syntax.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Syntax shortcut
Reply #4 - Nov 16th, 2007 at 7:28pm
Print Post Print Post  
OK, thank you Erika.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Syntax shortcut
Reply #5 - Nov 16th, 2007 at 9:23pm
Print Post Print Post  
Quote:
is not reliable when used with strings. That it works at all is coincidental, not intentional.

o this means that all earlier coding that includes += should be changed, is that correct?
Did I miss an announcement that said DO NOT USE "+=" because it is unreliable?
Will sample code in the manuals be modified?
Ah, just noticed the reference to "strings".  Does this imply that it is reliable with math?
----------------------------------------------------------
Would be good to be able to do a Mass Update to my programming.

Hmm, I can use Regular Expressions to do that, like this:
Find: ^(.*)\+=
Replace with: \1 = \1 \+

But, Sesame does not support RegEx replacements, so all I can do in Sesame is to locate the defective expressions.  So, for now I must export the program file to an editor that supports RegEx with replacements, run the RegEx Search/Replace, and import the file back in again.

PS - I just did that, and was able to do a global replacement.  Now I just need to go through all forms created in the past, export them, replace strings, and import them.

Maybe include RegEx replacement capablilties in future release?



  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Syntax shortcut
Reply #6 - Nov 16th, 2007 at 9:38pm
Print Post Print Post  
Bob_Hansen wrote on Nov 16th, 2007 at 9:23pm:
o this means that all earlier coding that includes += should be changed, is that correct?

You don't need to get crazy about it, but we'd rather this not be the thing everybody uses.

Quote:
Did I miss an announcement that said DO NOT USE "+=" because it is unreliable?

We have said it before. I'm not sure what you did or did not miss as I don't live in your head.  Smiley

Quote:
Will sample code in the manuals be modified?

I tried to strip it out of anywhere it was being used with strings. I may have missed some.

Quote:
Ah, just noticed the reference to "strings".  Does this imply that it is reliable with math?

It should be reliable with numbers. It will usually be reliable with strings, but since it is coincidental, we don't want to encourage its use.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Syntax shortcut
Reply #7 - Nov 16th, 2007 at 10:46pm
Print Post Print Post  
Quote:
I don't live in your head. 


My loss. Cry 
Would be glad to make room, clear out some clutter and improve the neighborhood! Wink

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Syntax shortcut
Reply #8 - Nov 26th, 2007 at 2:39pm
Print Post Print Post  
Quote:
I can use Regular Expressions to do that, like this:
Find: ^(.*)\+=
Replace with: \1 = \1 \+

But, Sesame does not support RegEx replacements, so all I can do in Sesame is to locate the defective expressions.  So, for now I must export the program file to an editor that supports RegEx with replacements, run the RegEx Search/Replace, and import the file back in again.

PS - I just did that, and was able to do a global replacement.  Now I just need to go through all forms created in the past, export them, replace strings, and import them.

Bob, I'm curious, what editor are you using that supports RegEx?
  

**
Captain Infinity
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Syntax shortcut
Reply #9 - Nov 26th, 2007 at 5:38pm
Print Post Print Post  
Infinity wrote on Nov 26th, 2007 at 2:39pm:
Bob, I'm curious, what editor are you using that supports RegEx?

I can't speak for Bob, but I use UltraEdit.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Syntax shortcut
Reply #10 - Nov 26th, 2007 at 6:50pm
Print Post Print Post  
I use the vi, vim, gvim family of editors. Older than Microsoft and still going strong.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Syntax shortcut
Reply #11 - Nov 26th, 2007 at 6:55pm
Print Post Print Post  
Quote:
I use the vi, vim, gvim family of editors.

Gesundheit.
  

**
Captain Infinity
Back to top
IP Logged