dbTalk Databases Forums  

d3 - How to check if variable is a filevariable ?

comp.databases.pick comp.databases.pick


Discuss d3 - How to check if variable is a filevariable ? in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Manu Fernandes
 
Posts: n/a

Default d3 - How to check if variable is a filevariable ? - 01-20-2007 , 04:42 AM






Dear group,

On D3

Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Is there some special func like FILEINFO(var,0) on Universe ?

Thanks for any help/comment.

Manu



Reply With Quote
  #2  
Old   
Frank Winans
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-20-2007 , 11:55 AM






"Manu Fernandes" wrote
Quote:
On D3 is there a way to check if a variable is a filevariable ?
Sadly, no there is not. This has been discussed here many times.



Reply With Quote
  #3  
Old   
Mike Preece
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 01:52 AM




Manu Fernandes wrote:

Quote:
Dear group,

On D3

Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Is there some special func like FILEINFO(var,0) on Universe ?

Thanks for any help/comment.

Manu
Google cdp for "WhatHaveIGot".

Cheers,
Mike.



Reply With Quote
  #4  
Old   
cmeister@tpsrx.com
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 08:25 AM



You can use the ASSIGNED function in D3.

:U BP.CTM FILE.OPEN.TEST

BP.CTM 'FILE.OPEN.TEST' size = 150
01 OPEN "BP.CTM" TO BP.CTM.FILE ELSE STOP 201, "BP.CTM"
02 IF ASSIGNED(BP.CTM.FILE) THEN CRT "File Opened" ELSE CRT "File NOT
Opened"
BP.CTM 'FILE.OPEN.TEST' size = 151 filed
FILE.OPEN.TEST
..
[241] Successful compile! 1 frame(s) used.
File Opened
:U BP.CTM FILE.OPEN.TEST

BP.CTM 'FILE.OPEN.TEST' size = 151
01 OPEN "BP.CTM" TO BP.CTM.FILE ELSE STOP 201, "BP.CTM"
02 IF ASSIGNED(OTHER.FILE) THEN CRT "File Opened" ELSE CRT "File NOT
Opened"
BP.CTM 'FILE.OPEN.TEST' size = 150 filed
FILE.OPEN.TEST
..
[241] Successful compile! 1 frame(s) used.
File NOT Opened
:


Mike Preece wrote:
Quote:
Manu Fernandes wrote:

Dear group,

On D3

Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Is there some special func like FILEINFO(var,0) on Universe ?

Thanks for any help/comment.

Manu

Google cdp for "WhatHaveIGot".

Cheers,
Mike.


Reply With Quote
  #5  
Old   
Frank Winans
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 08:28 AM



"Mike Preece" wrote>
Quote:
Manu Fernandes wrote:
On D3
Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Google cdp for "WhatHaveIGot".

Cheers,
Mike.
Oooh! I forgot about that aug 2000 posting; to wit

Subroutine WhatHaveIGot(FileVariable,WhatIsIt)
WhatIsIt=''
if not(assigned(FileVariable)) then
WhatIsIt = 'Unassigned'
return
end
clearselect CheckIds
select FileVariable to CheckIds
if CheckIds<2>='' then ;* This seems to be the key that unlocks it all
WhatIsIt = 'A variable'
return
end
readnext id from CheckIds else
WhatIsIt = 'An empty file'
return
end
read dummy from FileVariable,id else debug
clearselect CheckIds
fofid=oconv('','u90')
open 'fof' to foffv else debug
read fofitem from foffv,fofid else debug
WhatIsIt = fofitem<1>:',':fofitem<2>:',':fofitem<3>
return





Reply With Quote
  #6  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 01:05 PM



I may be mistaken but that code looks like it would abort as soon as
it attempted an operation on an invalid data type. The OP needs to
know what the variable type is, not die in the attempt to find out.

Without just echoing code has anyone actually tried the code on a
current release?

T

"Frank Winans" wrote:

Quote:
"Mike Preece" wrote
Manu Fernandes wrote:
On D3
Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Google cdp for "WhatHaveIGot".

Cheers,
Mike.
Oooh! I forgot about that aug 2000 posting; to wit

Subroutine WhatHaveIGot(FileVariable,WhatIsIt)
WhatIsIt=''
if not(assigned(FileVariable)) then
WhatIsIt = 'Unassigned'
return
end
clearselect CheckIds
select FileVariable to CheckIds
if CheckIds<2>='' then ;* This seems to be the key that unlocks it all
WhatIsIt = 'A variable'
return
end
readnext id from CheckIds else
WhatIsIt = 'An empty file'
return
end
read dummy from FileVariable,id else debug
clearselect CheckIds
fofid=oconv('','u90')
open 'fof' to foffv else debug
read fofitem from foffv,fofid else debug
WhatIsIt = fofitem<1>:',':fofitem<2>:',':fofitem<3
return




Reply With Quote
  #7  
Old   
Mike Preece
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 05:23 PM




Tony Gravagno wrote:

Quote:
I may be mistaken but that code looks like it would abort as soon as
it attempted an operation on an invalid data type. The OP needs to
know what the variable type is, not die in the attempt to find out.

Without just echoing code has anyone actually tried the code on a
current release?

T

What was that film?

Quote:
"Frank Winans" wrote:

"Mike Preece" wrote
Manu Fernandes wrote:
On D3
Do you known if there is a way to check if a variable is a filevariable
(result of a OPEN stmt) ?
I can check if a var is initialised, but with filevar I get errors.

Google cdp for "WhatHaveIGot".

Cheers,
Mike.
Oooh! I forgot about that aug 2000 posting; to wit

Subroutine WhatHaveIGot(FileVariable,WhatIsIt)
WhatIsIt=''
if not(assigned(FileVariable)) then
WhatIsIt = 'Unassigned'
return
end
clearselect CheckIds
select FileVariable to CheckIds
if CheckIds<2>='' then ;* This seems to be the key that unlocks it all
WhatIsIt = 'A variable'
return
end
readnext id from CheckIds else
WhatIsIt = 'An empty file'
return
end
read dummy from FileVariable,id else debug
clearselect CheckIds
fofid=oconv('','u90')
open 'fof' to foffv else debug
read fofitem from foffv,fofid else debug
WhatIsIt = fofitem<1>:',':fofitem<2>:',':fofitem<3
return




Reply With Quote
  #8  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 09:03 PM



"Mike Preece" wrote:
Quote:
What was that film?
Huh?


Reply With Quote
  #9  
Old   
Mike Preece
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-22-2007 , 10:28 PM




Tony Gravagno wrote:

Quote:
"Mike Preece" wrote:
What was that film?

Huh?
It was on again today.

I'm sure we've done this before - even though I can't find the previous
thread in the archives with a google search. It went on with your
question/challenge and culminated with you suggesting an alternative
work-around - a better one, actually - although WhatHaveIGot did work.

Mike.



Reply With Quote
  #10  
Old   
GVP
 
Posts: n/a

Default Re: d3 - How to check if variable is a filevariable ? - 01-23-2007 , 02:04 AM



Hi

Any empty file "MyDummyFile" should be present.


In PickBasic
* mvar is variable for test

tmpmvar=mvar

open "MyDummyFile" to tmpFileVar
close tmpFileVar

dummyFOFId=oconv("","u90")
close tmpmvar

mvarIsFileVar=0
IF dummyFOFId # oconv("","u90") THEN mvarIsFileVar=1


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.