March 29, 2024, 02:45:04 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Confusing compile errors using my first dialog

Started by arono, January 12, 2017, 12:49:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arono

Hi,

I'm attempting my first dialog which is subject to a parent window.  It will be displayed with the SHOWDIALOG command.

I am getting 3 error messages in the compile and I don't understand why.  Here is the code to define the dialog:
CreateDialog GameFileEdit_dialog,0,0,531,445,@MINBOX|@MAXBOX|@SIZE|@CAPTION|@SYSMENU,0,"GFEdialog",&GameFileEdit_dialog_handler
   CONTROL GameFileEdit_dialog,@STATIC,"Game File Edit",97,15,278,25,@SS_SIMPLE,GameFileEdit_dialog_STATIC1
   CONTROL GameFileEdit_dialog,@STATIC,"Game File Description:",44,68,176,25,@SS_SIMPLE,GameFileEdit_STATIC2
   CONTROL GameFileEdit_dialog,@EDIT,"Game Description",223,69,243,25,@CTEDITLEFT,GameFileEdit_Desc
   CONTROL GameFileEdit_dialog,@STATIC,"Starting Screen:",43,106,124,25,@SS_LEFT,GameFileEdit_dialog_STATIC3
   CONTROL GameFileEdit_dialog,@EDIT,"Starting Screen",224,108,32,25,@CTEDITLEFT,GameFileEdit_Screen

Here are the error messages I'm getting:
   Error: Undefined variable GameFileEdit_dialog_STATIC1
   Error: Undefined variable GameFileEdit_STATIC2
   Error: Undefined variable GameFileEdit_Desc

Just for the heck of it I commented out the first line getting an error (STATIC1) and the next compile complained about the 3 lines after it (STATIC2, Desc and STATIC3)!!!!

Anybody have any ideas?

Thanks.

billhsln

January 12, 2017, 02:11:52 PM #1 Last Edit: January 12, 2017, 02:15:42 PM by billhsln
It is telling you what it wants.

You can fix this 2 ways:

1)

DEF GameFileEdit_dialog_STATIC1 = 100:INT
DEF GameFileEdit_STATIC2 = 101
DEF GameFileEdit_STATIC3 = 102
DEF GameFileEdit_Desc = 103
DEF GameFileEdit_Screen = 104

2)

ENUM GameFileEdit
  GameFileEdit_dialog_STATIC1 = 200
  GameFileEdit_STATIC2
  GameFileEdit_STATIC3
  GameFileEdit_Desc
  GameFileEdit_Screen
ENDNUM

With ENUM you end up with 200, 201, 202, 203 and 204.

The numbers don't matter as long as they are not the same.

I personally prefer to use the ENUM, since then when you add another field, just add it any where in the ENUM and you don't have to worry about what its number is.

Bill
When all else fails, get a bigger hammer.


arono

Bill,

A couple more questions:

In your ENUM example, you assigned the ID names I used in my dialog Controls to ID numbers.   You associated the ENUM to my dialog name, then listed the Control ID names in my dialog.  ENUM then sequentially assigned ID numbers to each of them. 

I will also have 'independent' controls (buttons for instance) that will not be grouped with any dialog or anything else.  Can an ENUM be used for these as well?   If so, would the ENUM be coded something like: "ENUM  MyIndependentControls" and then enter all of my 'independents' here?   Could I not create just one ENUM for the program and list all Controls in it?

Thanks again Bill.


billhsln

Here is one I used, it has D1 is a Dialog, W2, W3 and W4 are windows.  3rd char is B for button, CB is checkbox, E is for edit, S is for static, L is a listview, P and M's are also buttons, but special single character ones.

ENUM ControlIDs
D1_B1 = 500
D1_B2
D1_B3
D1_B4
D1_B5
D1_B6
D1_B7
D1_B8
D1_B9
D1_B10
D1_B11
D1_B12
D1_P1
D1_P2
D1_M1
D1_M2
D1_CB1
D1_CB2
D1_CB3
D1_CB4
D1_EP
D1_EC1
D1_EC2
D1_E1
D1_E2
D1_E3
D1_E4
D1_E5
D1_E6
D1_EU
D1_SN
D1_S1
D1_S2
D1_S3
D1_S4
D1_S5
D1_S6
D1_S7
D1_S8
D1_SU
D1_SR
D1_L1
W2_E1
W2_E2
W2_B1
W2_B2
W3_L1
W4_E1
W4_E2
W4_E3
W4_S1
W4_S2
W4_S3
W4_G1
W4_G2
W4_B00
W4_B01
W4_B02
W4_B03
W4_B04
W4_B05
W4_B06
W4_B07
W4_B08
W4_B09
W4_B10
W4_B11
W4_B01S
W4_B02S
W4_B03S
W4_B04S
W4_B01N
W4_B02N
W4_B01A
W4_B02A
W4_B03A
W4_B04A
W4_B05A
W4_B06A
W4_B07A
W4_B08A
W4_B09A
W4_B10A
W4_B11A
ENDENUM


This is what I use.

Bill
When all else fails, get a bigger hammer.

arono

Thanks again Bill.  My first dialog is working great and I'll use your idea of a 'global' ENUM statement.

billhsln

Just wanted to mention that I am an old programmer and worked with BASIC back when 2 characters is what you had for field variables.  Which is why I do the Dx for Dialogs and Wx for Windows.  I do use some field names that are more descriptive now, but still use very short field names even now.

Since you are new at this, keep using the more descriptive names.  It will help you when you go back and need to change your program a year from now and don't remember why or what every thing was used for.

Bill
When all else fails, get a bigger hammer.