The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Text, Numbers and Blanks

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kid Posted - 08/23/2001 : 3:36:24 PM
how can, if it can, labtalk know if it's looking at a string, a number or a blank cell?

Alex
4   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 10/24/2003 : 6:09:22 PM
how about this

%A=cell(x,y)$;

if (%A=="" || %A=="--")
{
type -b Cell contains no value.;
}
else {
type -b "The cell value is %A";

}



CP




tib Posted - 10/24/2003 : 2:01:13 PM
Is there anything better in the meantime?

My problem is even simpler:
I just wanted to test if there is any thing in the cell or not.
I thought the following would do the job

if (%[%(%H,x,y)]==0) {type -b Cell contains no value.}
else {type -b The cell value is %(%H,x,y)};

This should give 0 for empty or non existing cell
and any a value > 0 for a cell with content.

However, with empty cells (or not existing cells) I get back some arbitrary strange numbers, i.e. 2, 11, 17... for %[%(%H,x,y)]
Any ideas why?
Tilman.



Mike Buess Posted - 08/31/2001 : 09:29:17 AM
This problem with evaluating strings containing "=" intrigued me so I did some testing.
// Test 1
if( %A==0/0 ) type string;
else type number;

// Test 2
if( %A!=0/0 ) type number;
else type string;

// Test 3
if( %A!="=" ) type not "=";
else type "=";

// Test 4
if( %A=="--" ) type "--";
else type not "--";

// Test 5
if( "%A"=="--" ) type "--";
else type not "--";
The results for various strings containing "=" are given in the table below.



%ATest 1Test 2Test 3Test 4Test 5
=stringnumber=--not --
a=bnumberstringnot =not --not --
=bnumberstringnot =not --not --
a=stringstringnot =--not --

If we want all strings containing "=" to evaluate as strings rather than numbers or missing values (--) then we can use tests 2, 3 and 5 as follows. (I'm assuming that we're testing the contents of cells in column B of the active worksheet.)
%A=col(B)[n]$;
%S=string;
if( "%A"=="--" ) %S=missing value;
if( %A!=0/0 && %A!="=" ) %S=number;
type Row $(n) contains a %S.;
I didn't include a test for blank cells (%A="") because they will be filled with "--" when the worksheet window refreshes.

Mike Buess
Origin WebRing Member

P.S. I should have pointed out that Tests 1 and 2 contain the fuzzy logic with regard to "=". When %A="=" both (%A==0/0) and (%A!=0/0) are true. When %A="a=b" or "=b" both are false. Only when %A="a=" is one true and the other false, in which case both tests give the correct answer.

Edited by - Mike Buess on 08/31/2001 09:33:20

Edited by - Mike Buess on 08/31/2001 09:37:45

Edited by - Mike Buess on 08/31/2001 11:19:13
CStorey Posted - 08/23/2001 : 6:26:24 PM
You could try something like the code below...then you could search through the %R string and pick out the numbers. Beware there are limitations to this script!

I never bothered to report the wierd behaviour of the "=" == VALUE comparison. Is this result supposed to occur?

// Return number if char. 1 is a number.
// Fails for %A="E-N"; where N is a number (i.e. recognizes Exponential Notation)
// Fails if %A contains an "=" anywhere. (Doesn't like to compare "=" == Value)

type.redirection=1;
%A="Not a number, but neither is 0 really.";
%R=""; ///results string

len=%[%A];

If (len>0)
{
// Is it only a number???
If ($(%A)!="--")
{
type "String is number! $(%A)";
}
// Does it contain numbers????
Else
{
For(aaa=1; aaa<=len; aaa++)
{
//type "--> $(aaa) - %[%A, aaa:aaa]";
If (%[%A, aaa:aaa]=="0") { %R="%R/0@c$(aaa)";};
If (%[%A, aaa:aaa]=="1") { %R="%R/1@c$(aaa)";};
If (%[%A, aaa:aaa]=="2") { %R="%R/2@c$(aaa)";};
If (%[%A, aaa:aaa]=="3") { %R="%R/3@c$(aaa)";};
If (%[%A, aaa:aaa]=="4") { %R="%R/4@c$(aaa)";};
If (%[%A, aaa:aaa]=="5") { %R="%R/5@c$(aaa)";};
If (%[%A, aaa:aaa]=="6") { %R="%R/6@c$(aaa)";};
If (%[%A, aaa:aaa]=="7") { %R="%R/7@c$(aaa)";};
If (%[%A, aaa:aaa]=="8") { %R="%R/8@c$(aaa)";};
If (%[%A, aaa:aaa]=="9") { %R="%R/9@c$(aaa)";};
};
If (%[%R]>0)
{
type "String is $(len) chars long. Is NOT a NUMBER. But contains numbers at %R.";
}
Else
{
type "String is $(len) chars long. Is NOT a NUMBER. DOES NOT contain any numbers.";
};
};
}
Else
{
type -b "String is a BLANK";
};
Return;

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000