numberformat woes?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

numberformat woes?

Richard Gaskin via use-livecode
Hi friends,

this snippet:
...
set the numberformat to 0000
put EMPTY into tNextNr
if tNextNr = EMPTY then
  put 1 + 0 into tNewNext
else
  put tNextNr + 1 into tNewNext
end if
put tNewNext
...
-> 0001

However if I put this into a function:
function fNextNr
  set the numberformat to 0000
  put the cLetzteLaufendeNummer of this stack into tNextNr
  if tNextNr = EMPTY then
      put 1 + 0 into tNewNext
  else
      put tNextNr + 1 into tNewNext
  end if
  set the cLetzteLaufendeNummer of this stack to tNewNext
  return tNewNext
end fNextNr

tNewNext = 1 (If tNextNr = EMPTY, resp 2,3,4..., if not)?

What am I missing?
LC 9.5, macOS 10.14.6

Thanks a lot in advance!


Best

Klaus
--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
Hallo Klaus,

Umm, thinking loudly, I would say numberformat has a local scope ...


Regards,

Thierry

What am I missing?
>
> Klaus

--
------------------------------------------------
Thierry Douez - sunny-tdz.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
Bonjour Thierry,

> Am 07.11.2019 um 14:09 schrieb Thierry Douez via use-livecode <[hidden email]>:
>
> Hallo Klaus,
>
> Umm, thinking loudly, I would say numberformat has a local scope ...

ah, that was what I was missing, merci, mon ami!

But see below...

function fNextNr
 set the numberformat to 0000
 put the cLetzteLaufendeNummer of this stack into tNextNr
 if tNextNr = EMPTY then
     put 1 + 0 into tNewNext
 else
     put tNextNr + 1 into tNewNext
 end if
 ## !!
 ## However this line IS Inside of the local cope of numberformat
 set the cLetzteLaufendeNummer of this stack to tNewNext
 ## !!
 return tNewNext
end fNextNr

So -> the cLetzteLaufendeNummer of this stack should result in e.g. 0003 but is in fact 3?
At least this is shown in the Custom Property departement of the inspector for my stack.

Hm, it is getting even stranger, maybe I just don't get it? :-D
This:
...
put the cLetzteLaufendeNummer of this stack
...
-> 3

But this:
...
set the numberformat to 0000
put the cLetzteLaufendeNummer of this stack
...
-> 0003

No arithmetic operation involved!?

> Regards,
>
> Thierry

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
You are saving a number and not a string.  Numberformat governs how a number is displayed as a string doesn’t it?

Thanks,
Brian
On Nov 7, 2019, 8:19 AM -0500, Klaus major-k via use-livecode <[hidden email]>, wrote:

> Bonjour Thierry,
>
> > Am 07.11.2019 um 14:09 schrieb Thierry Douez via use-livecode <[hidden email]>:
> >
> > Hallo Klaus,
> >
> > Umm, thinking loudly, I would say numberformat has a local scope ...
>
> ah, that was what I was missing, merci, mon ami!
>
> But see below...
>
> function fNextNr
> set the numberformat to 0000
> put the cLetzteLaufendeNummer of this stack into tNextNr
> if tNextNr = EMPTY then
> put 1 + 0 into tNewNext
> else
> put tNextNr + 1 into tNewNext
> end if
> ## !!
> ## However this line IS Inside of the local cope of numberformat
> set the cLetzteLaufendeNummer of this stack to tNewNext
> ## !!
> return tNewNext
> end fNextNr
>
> So -> the cLetzteLaufendeNummer of this stack should result in e.g. 0003 but is in fact 3?
> At least this is shown in the Custom Property departement of the inspector for my stack.
>
> Hm, it is getting even stranger, maybe I just don't get it? :-D
> This:
> ...
> put the cLetzteLaufendeNummer of this stack
> ...
> -> 3
>
> But this:
> ...
> set the numberformat to 0000
> put the cLetzteLaufendeNummer of this stack
> ...
> -> 0003
>
> No arithmetic operation involved!?
>
> > Regards,
> >
> > Thierry
>
> Best
>
> Klaus
>
> --
> Klaus Major
> https://www.major-k.de
> [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Hi Klaus

Had a similar issue. To overcome I just added “” afterward. Sounds counterintuitive but worked. So:

Put tNextNr + “” into cLetzteLaufendeNummer

Sean Cole
Pi Digital Prod Ltd

> On 7 Nov 2019, at 13:19, Klaus major-k via use-livecode <[hidden email]> wrote:
>
> Bonjour Thierry,
>
>> Am 07.11.2019 um 14:09 schrieb Thierry Douez via use-livecode <[hidden email]>:
>>
>> Hallo Klaus,
>>
>> Umm, thinking loudly, I would say numberformat has a local scope ...
>
> ah, that was what I was missing, merci, mon ami!
>
> But see below...
>
> function fNextNr
> set the numberformat to 0000
> put the cLetzteLaufendeNummer of this stack into tNextNr
> if tNextNr = EMPTY then
>     put 1 + 0 into tNewNext
> else
>     put tNextNr + 1 into tNewNext
> end if
> ## !!
> ## However this line IS Inside of the local cope of numberformat
> set the cLetzteLaufendeNummer of this stack to tNewNext
> ## !!
> return tNewNext
> end fNextNr
>
> So -> the cLetzteLaufendeNummer of this stack should result in e.g. 0003 but is in fact 3?
> At least this is shown in the Custom Property departement of the inspector for my stack.
>
> Hm, it is getting even stranger, maybe I just don't get it? :-D
> This:
> ...
> put the cLetzteLaufendeNummer of this stack
> ...
> -> 3
>
> But this:
> ...
> set the numberformat to 0000
> put the cLetzteLaufendeNummer of this stack
> ...
> -> 0003
>
> No arithmetic operation involved!?
>
>> Regards,
>>
>> Thierry
>
> Best
>
> Klaus
>
> --
> Klaus Major
> https://www.major-k.de
> [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Hi Brian,

> Am 07.11.2019 um 14:21 schrieb Brian Milby via use-livecode <[hidden email]>:
>
> You are saving a number and not a string.  

aha, thanks, that makes it clearer!

> Numberformat governs how a number is displayed as a string doesn’t it?

No idea, you are the LC Pro, does it? 8-)

> Thanks,
> Brian
> On Nov 7, 2019, 8:19 AM -0500, Klaus major-k via use-livecode <[hidden email]>, wrote:
>> Bonjour Thierry,
>>
>>> Am 07.11.2019 um 14:09 schrieb Thierry Douez via use-livecode <[hidden email]>:
>>>
>>> Hallo Klaus,
>>>
>>> Umm, thinking loudly, I would say numberformat has a local scope ...
>>
>> ah, that was what I was missing, merci, mon ami!
>>
>> But see below...
>>
>> function fNextNr
>> set the numberformat to 0000
>> put the cLetzteLaufendeNummer of this stack into tNextNr
>> if tNextNr = EMPTY then
>> put 1 + 0 into tNewNext
>> else
>> put tNextNr + 1 into tNewNext
>> end if
>> ## !!
>> ## However this line IS Inside of the local cope of numberformat
>> set the cLetzteLaufendeNummer of this stack to tNewNext
>> ## !!
>> return tNewNext
>> end fNextNr
>>
>> So -> the cLetzteLaufendeNummer of this stack should result in e.g. 0003 but is in fact 3?
>> At least this is shown in the Custom Property departement of the inspector for my stack.
>>
>> Hm, it is getting even stranger, maybe I just don't get it? :-D
>> This:
>> ...
>> put the cLetzteLaufendeNummer of this stack
>> ...
>> -> 3
>>
>> But this:
>> ...
>> set the numberformat to 0000
>> put the cLetzteLaufendeNummer of this stack
>> ...
>> -> 0003
>>
>> No arithmetic operation involved!?

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Hi Sean,

> Am 07.11.2019 um 14:28 schrieb Pi Digital via use-livecode <[hidden email]>:
>
> Hi Klaus
>
> Had a similar issue. To overcome I just added “” afterward. Sounds counterintuitive but worked. So:
> Put tNextNr + “” into cLetzteLaufendeNummer

so this does not count obviously:
...
if tNextNr = EMPTY then
   put 1 + 0 into tNewNext
else
   put tNextNr + 1 into tNewNext
end if
set the cLetzteLaufendeNummer of this stack to tNewNext
...

This IS in fact a bit puzzling, but I get along now, thanks. :-)

> Sean Cole

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Sorry, not + but &.

> Put tNextNr & “” into cLetzteLaufendeNummer

Sean Cole
Pi Digital Prod Ltd

> On 7 Nov 2019, at 13:29, Pi Digital via use-livecode <[hidden email]> wrote:
>
> Hi Klaus
>
> Had a similar issue. To overcome I just added “” afterward. Sounds counterintuitive but worked. So:
>
> Put tNextNr + “” into cLetzteLaufendeNummer
>
> Sean Cole
> Pi Digital Prod Ltd
>
>> On 7 Nov 2019, at 13:19, Klaus major-k via use-livecode <[hidden email]> wrote:
>>
>> Bonjour Thierry,
>>
>>>> Am 07.11.2019 um 14:09 schrieb Thierry Douez via use-livecode <[hidden email]>:
>>>
>>> Hallo Klaus,
>>>
>>> Umm, thinking loudly, I would say numberformat has a local scope ...
>>
>> ah, that was what I was missing, merci, mon ami!
>>
>> But see below...
>>
>> function fNextNr
>> set the numberformat to 0000
>> put the cLetzteLaufendeNummer of this stack into tNextNr
>> if tNextNr = EMPTY then
>>    put 1 + 0 into tNewNext
>> else
>>    put tNextNr + 1 into tNewNext
>> end if
>> ## !!
>> ## However this line IS Inside of the local cope of numberformat
>> set the cLetzteLaufendeNummer of this stack to tNewNext
>> ## !!
>> return tNewNext
>> end fNextNr
>>
>> So -> the cLetzteLaufendeNummer of this stack should result in e.g. 0003 but is in fact 3?
>> At least this is shown in the Custom Property departement of the inspector for my stack.
>>
>> Hm, it is getting even stranger, maybe I just don't get it? :-D
>> This:
>> ...
>> put the cLetzteLaufendeNummer of this stack
>> ...
>> -> 3
>>
>> But this:
>> ...
>> set the numberformat to 0000
>> put the cLetzteLaufendeNummer of this stack
>> ...
>> -> 0003
>>
>> No arithmetic operation involved!?
>>
>>> Regards,
>>>
>>> Thierry
>>
>> Best
>>
>> Klaus
>>
>> --
>> Klaus Major
>> https://www.major-k.de
>> [hidden email]
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
Hi Sean,

> Am 07.11.2019 um 14:33 schrieb Pi Digital via use-livecode <[hidden email]>:
>
> Sorry, not + but &.

oops, sorry.

Ah yes, makes sense, this forces the result to be a STRING.

A clever trick and really new to me (after using LC and its ancestors
for 20 years now), thank you very much! :-)

>> Put tNextNr & “” into cLetzteLaufendeNummer
> Sean Cole

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Klaus, a better property name would be
Donaudampfschifffahrtsgesellschaftkapitänskajütenschlüsselloch ;-)


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
Hallo Hermann,

> Am 07.11.2019 um 15:01 schrieb hh via use-livecode <[hidden email]>:
>
> Klaus, a better property name would be
> Donaudampfschifffahrtsgesellschaftkapitänskajütenschlüsselloch ;-)

LOL! :-D

I only knew the shorter "Donaudampfschifffahrtsgesellschaftkapitänsmütze" so far.
Good idea in general, but not meaningful enough for my project. ;-)


Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
But with a c at the beginning ;)
Hehe, you guys :D

Sean Cole
Pi Digital Prod Ltd

> On 7 Nov 2019, at 14:01, hh via use-livecode <[hidden email]> wrote:
>
> Klaus, a better property name would be
> Donaudampfschifffahrtsgesellschaftkapitänskajütenschlüsselloch ;-)
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: numberformat woes?

Richard Gaskin via use-livecode


> Am 07.11.2019 um 15:12 schrieb Pi Digital via use-livecode <[hidden email]>:
>
> But with a c at the beginning ;)

Conaudampfschifffahrtsgesellschaftkapitänschlüsselloch?
Come on! :-D

> Hehe, you guys :D

Germans...

> Sean Cole
> Pi Digital Prod Ltd

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode