Can you check for string parameters without a magic number?
|
11-15-2017, 09:43 PM
(This post was last modified: 11-15-2017 11:43 PM by StephenG1CMZ.)
Post: #1
|
|||
|
|||
Can you check for string parameters without a magic number?
You can check for floats, integers, lists etc. In PPL.
Can you detect a string too? Without using a magic number... Code:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
11-16-2017, 12:20 AM
Post: #2
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
Exists:
type() → CAS TYPE() → Home Viga C | TD | FB |
|||
11-16-2017, 07:09 AM
Post: #3
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
Using type instead of TYPE even though I am in PPL not CAS doesnt seem to help
Code:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
11-16-2017, 07:28 AM
Post: #4
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
In Home → TYPE
Code: Syntax: In CAS → type (CAS.type in Home) Code: Syntax: The types in Home and CAS are different, they are not related, for example the format #FFh for integers in CAS does not exist Viga C | TD | FB |
|||
11-16-2017, 07:37 AM
Post: #5
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
Uso común: TYPE(n)
Code: EXPORT TypeString(n) Viga C | TD | FB |
|||
11-19-2017, 03:05 AM
(This post was last modified: 11-19-2017 03:14 AM by TravisE.)
Post: #6
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
If I understand the OP correctly, they want to compare the types without directly using numeric constants.
(11-16-2017 07:09 AM)StephenG1CMZ Wrote: Using type instead of TYPE even though I am in PPL not CAS doesnt seem to help From playing around a bit, it looks like it's necessary to: 1. Call the CAS type function with “CAS.type()” 2. Don't subtract 1 from the DOM_* constants you're comparing to (I'm not sure why you're doing that) The PPL TYPE() function appears to returns a different set of values, so comparing its return values to the DOM_* constants isn't appropriate. If you really want to avoid using a magic number there, you could either define your own named constants in your program, or you could possibly use something like: Code:
etc. |
|||
11-19-2017, 08:00 AM
(This post was last modified: 11-20-2017 06:43 AM by StephenG1CMZ.)
Post: #7
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
(11-19-2017 03:05 AM)TravisE Wrote: If I understand the OP correctly, they want to compare the types without directly using numeric constants. Thanks for that tip. Using IF TYPE(...)==TYPE(1.2) etc. Seems the best way to avoid using constants like 3-1, or even DOM_STRING, which can lead you astray. To avoid having a 1.2 here and a PI there, which would be distracting, I'd perhaps use MY_DOM_FLOAT==TYPE(1.2) IF TYPE(...)==MY_DOM_FLOAT Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
11-20-2017, 04:38 AM
Post: #8
|
|||
|
|||
RE: Can you check for string parameters without a magic number?
* In Home
Code: IF TYPE(VAR)=0 THEN ... //REAL * In Home with type (CAS) Code: IF CAS.type(VAR)=1 THEN ... //REAL Viga C | TD | FB |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)