Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently April 22nd, 2025, 11:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Boolean variable
PostPosted: March 13th, 2005, 9:43 am 
Offline

Joined: February 4th, 2005, 5:59 am
Posts: 81
Location: Bristol, UK
Is there any way of creating a publication level boolean variable? The options seem to be text, number or array...

Thanks,

Melanie

_________________
Win XP, 3.4 HT P4, 1GB ram, Nvidia Geforce 6610 XL, DirectX 9.0c
Opus Pro 04 XE version 4.50
Opus 2.81


For this message Melanie has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 14th, 2005, 12:06 am 
Offline

Joined: October 25th, 2004, 1:03 pm
Posts: 74
Location: Sydney Australia
I just use "1" or "0" as a number.


For this message SWAN has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Boolean variable
PostPosted: March 14th, 2005, 11:37 pm 
Offline

Joined: February 4th, 2005, 5:59 am
Posts: 81
Location: Bristol, UK
Thanks Swan,

I'll see if I can work with something like you suggest. The trouble is I can't set an initial value of true (or false) to a publication level variable, and I'm using that variable with the button/Checkbox/Linktovariable thingy. This uses a boolean and presumably declares it as a boolean at some point, but because I have only number, text or array to pick, I can't initialise it to true or false.

I know I can use "button is initially down" to set it, to set it to true or false, but I wouldn't expect that to happen until that particular page loads.

This is what I'm proposing to do: I'm getting boolean values from a database and updating these pub level variables (sort of user preferences), so a variable declared as "text" is going to be updated to a bool, is this going to work?

Thanks for your help
:D
Melanie

_________________
Win XP, 3.4 HT P4, 1GB ram, Nvidia Geforce 6610 XL, DirectX 9.0c
Opus Pro 04 XE version 4.50
Opus 2.81


For this message Melanie has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 15th, 2005, 10:28 pm 
Offline

Joined: October 25th, 2004, 1:03 pm
Posts: 74
Location: Sydney Australia
I think most databases keeps a one byte bool as a 1 or a 0 anyway. I just checked mySQL & Access and they seem to.
In fact all the ASP & PHP code I do for checking the state of a bool is for a 1 or 0 (it works the same as checking for true or false). Although, I'm saying this without first checking it in Opus. I also have never worked a database from Opus either, so I hope I'm not leading U down the garden path.

I'll do a quick test.


For this message SWAN has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 16th, 2005, 1:48 am 
Offline

Joined: October 25th, 2004, 1:03 pm
Posts: 74
Location: Sydney Australia
Stick with numbers not text.
Code:
myDB = new Database("DSN=myDSN;")
Rset = myDB.ExecuteSQL("SELECT unit FROM products WHERE id = 11;")
var temp = 1
if (Rset.FirstRecord()==temp)
{
    Debug.trace("True")
}else{
    Debug.trace("False")
}

This worked for both Access (yes/no) bool and mySQL (tinyint).

This is the first time I've played with database on Opus. It's a bit strange to work with. I didn't spend a real lot of time on it but I couldn't see how to select column.record in a multi column recordset.

So Melanie, I trust with this you may be able to thrash it out from here.

Goo Luck ...


For this message SWAN has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Thanks Swan
PostPosted: March 16th, 2005, 2:44 am 
Offline

Joined: February 4th, 2005, 5:59 am
Posts: 81
Location: Bristol, UK
Thanks for that, I'm just snooping around the Database stuff at the moment - I'm comfortable with SQL but I'm still learning the script.

Seems that 1 (number) is treated as equivalent to TRUE (bool). Useful to know... I think :?

Quote:
I couldn't see how to select column.record in a multi column recordset


I don't understand what you mean here. Normally columns are prefixed by tablename ... for example:

var rset = mydb.ExecuteSQL("select dept.deptno, dept.deptname from dept;")

then to use deptno or deptname: -

rset.FirstRecord();
mydeptnovariable = rset.deptno

kind of thing... :D Dunno if that helps answer your question...(also hope this is right, I can't open Opus to test it at the moment because of another problem!)

Anyway, thanks for your help and I'll play around with it as soon as Opus is well again.

Cheers Melanie

_________________
Win XP, 3.4 HT P4, 1GB ram, Nvidia Geforce 6610 XL, DirectX 9.0c
Opus Pro 04 XE version 4.50
Opus 2.81


For this message Melanie has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 16th, 2005, 11:07 am 
Offline

Joined: October 25th, 2004, 3:09 pm
Posts: 32
Code:
myDB = new Database("DSN=myDSN;")
Rset = myDB.ExecuteSQL("SELECT unit FROM products WHERE id = 11;")
var temp = 1
if (Rset.FirstRecord()==temp)
{
    Debug.trace("True")
}else{
    Debug.trace("False")
}


What you are testing is if FirstRecord() got the first record so even if unit was a string the output would be true. You would only get false if FirstRecord() failed. What you want is

Code:
if (Rset.FirstRecord() == true) {
    if (Rset.unit == 1) {
        Debug.trace("True");
    } else {
        Debug.trace("False);
    }
}
[/code]


For this message Tony Coleman has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 18th, 2005, 5:35 am 
Offline

Joined: February 4th, 2005, 5:59 am
Posts: 81
Location: Bristol, UK
Thanks Tony for clarifying everything so elegantly :D

_________________
Win XP, 3.4 HT P4, 1GB ram, Nvidia Geforce 6610 XL, DirectX 9.0c
Opus Pro 04 XE version 4.50
Opus 2.81


For this message Melanie has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group